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