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 (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "lo-utils.h" |
|
32 |
|
33 #include "comment-list.h" |
|
34 #include "error.h" |
|
35 |
|
36 #include "SLList.h" |
|
37 #include "SLList.cc" |
|
38 |
|
39 template SLList<octave_comment_elt>; |
|
40 |
|
41 octave_comment_buffer *octave_comment_buffer::instance = 0; |
|
42 |
|
43 bool |
|
44 octave_comment_buffer::instance_ok (void) |
|
45 { |
|
46 bool retval = true; |
|
47 |
|
48 if (! instance) |
|
49 instance = new octave_comment_buffer (); |
|
50 |
|
51 if (! instance) |
|
52 { |
|
53 ::error ("unable to create comment buffer object"); |
|
54 |
|
55 retval = false; |
|
56 } |
|
57 |
|
58 return retval; |
|
59 } |
|
60 |
|
61 void |
|
62 octave_comment_buffer::append (const std::string& s, |
|
63 octave_comment_elt::comment_type t) |
|
64 { |
|
65 if (instance_ok ()) |
|
66 instance->do_append (s, t); |
|
67 } |
|
68 |
|
69 |
|
70 octave_comment_list * |
|
71 octave_comment_buffer::get_comment (void) |
|
72 { |
|
73 return (instance_ok ()) ? instance->do_get_comment () : 0; |
|
74 } |
|
75 |
|
76 void |
|
77 octave_comment_buffer::do_append (const std::string& s, |
|
78 octave_comment_elt::comment_type t) |
|
79 { |
|
80 comment_list->append(s, t); |
|
81 } |
|
82 |
|
83 octave_comment_list * |
|
84 octave_comment_buffer::do_get_comment (void) |
|
85 { |
|
86 octave_comment_list *retval = 0; |
|
87 |
|
88 if (comment_list && comment_list->length () > 0) |
|
89 { |
|
90 retval = comment_list; |
|
91 comment_list = new octave_comment_list (); |
|
92 } |
|
93 |
|
94 return retval; |
|
95 } |
|
96 |
|
97 /* |
|
98 ;;; Local Variables: *** |
|
99 ;;; mode: C++ *** |
|
100 ;;; End: *** |
|
101 */ |