3665
|
1 /* |
|
2 |
|
3 Copyright (C) 2000 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_comment_list_h) |
|
24 #define octave_comment_list_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
3665
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 #include <SLList.h> |
|
33 |
|
34 extern std::string get_comment_text (void); |
|
35 |
|
36 extern char *get_comment_text_c_str (void); |
|
37 |
|
38 extern void save_comment_text (const std::string& text); |
|
39 |
|
40 class |
|
41 octave_comment_elt |
|
42 { |
|
43 public: |
|
44 |
|
45 enum comment_type |
|
46 { |
|
47 unknown, |
|
48 block, |
|
49 end_of_line, |
|
50 doc_string, |
|
51 copyright |
|
52 }; |
|
53 |
|
54 octave_comment_elt (const std::string& s = std::string (), |
|
55 comment_type t = unknown) |
|
56 : txt (s), typ (t) { } |
|
57 |
|
58 octave_comment_elt (const octave_comment_elt& oc) |
|
59 : txt (oc.txt), typ (oc.typ) { } |
|
60 |
|
61 octave_comment_elt& operator = (const octave_comment_elt& oc) |
|
62 { |
|
63 if (this != &oc) |
|
64 { |
|
65 txt = oc.txt; |
|
66 typ = oc.typ; |
|
67 } |
|
68 |
|
69 return *this; |
|
70 } |
|
71 |
|
72 std::string text (void) const { return txt; } |
|
73 |
|
74 comment_type type (void) const { return typ; } |
|
75 |
|
76 ~octave_comment_elt (void) { } |
|
77 |
|
78 private: |
|
79 |
|
80 // The text of the comment. |
|
81 std::string txt; |
|
82 |
|
83 // The type of comment. |
|
84 comment_type typ; |
|
85 }; |
|
86 |
|
87 class |
4212
|
88 octave_comment_list |
3665
|
89 { |
|
90 public: |
|
91 |
4212
|
92 octave_comment_list (void) : lst () { } |
3665
|
93 |
|
94 ~octave_comment_list (void) { } |
|
95 |
4212
|
96 void append (const std::string& s, |
|
97 octave_comment_elt::comment_type t = octave_comment_elt::unknown) |
|
98 { lst.append (octave_comment_elt (s, t)); } |
3665
|
99 |
|
100 octave_comment_list (const octave_comment_list& ocb) |
4212
|
101 : lst (ocb.lst) { } |
3665
|
102 |
|
103 octave_comment_list& operator = (const octave_comment_list& ocb) |
|
104 { |
|
105 if (this != &ocb) |
4212
|
106 lst = ocb.lst; |
3665
|
107 |
|
108 return *this; |
|
109 } |
4212
|
110 |
|
111 int length (void) const { return lst.length (); } |
|
112 |
|
113 octave_comment_elt& operator () (Pix p) { return lst (p); } |
|
114 |
|
115 const octave_comment_elt& operator () (Pix p) const { return lst (p); } |
|
116 |
|
117 Pix first (void) const { return lst.first (); } |
|
118 |
|
119 void next (Pix& p) const { return lst.next (p); } |
|
120 |
|
121 private: |
|
122 |
|
123 // The list of comments. |
|
124 SLList<octave_comment_elt> lst; |
3665
|
125 }; |
|
126 |
|
127 class |
|
128 octave_comment_buffer |
|
129 { |
|
130 public: |
|
131 |
|
132 octave_comment_buffer (void) |
|
133 : comment_list (new octave_comment_list) { } |
|
134 |
|
135 static bool instance_ok (void); |
|
136 |
|
137 static void append |
|
138 (const std::string& s, |
|
139 octave_comment_elt::comment_type t = octave_comment_elt::unknown); |
|
140 |
|
141 static octave_comment_list *get_comment (void); |
|
142 |
|
143 private: |
|
144 |
|
145 void do_append (const std::string& s, octave_comment_elt::comment_type t); |
|
146 |
|
147 octave_comment_list *do_get_comment (void); |
|
148 |
|
149 octave_comment_list *comment_list; |
|
150 |
|
151 static octave_comment_buffer *instance; |
|
152 }; |
|
153 |
|
154 #endif |
|
155 |
|
156 /* |
|
157 ;;; Local Variables: *** |
|
158 ;;; mode: C++ *** |
|
159 ;;; End: *** |
|
160 */ |