Mercurial > octave
annotate libinterp/corefcn/pager.h @ 23060:baf03cdb28b5
move pager and diary classes into octave namespace
* pager.h, pager.cc (pager_buf, pager_stream, diary_buf,
diary_stream): Move into octave namespace and rename without octave_
prefix. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Jan 2017 14:25:51 -0500 |
parents | f75d289645ec |
children | ef4d915df748 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_pager_h) |
383 | 24 #define octave_pager_h 1 |
1 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
27 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
28 #include <iosfwd> |
5765 | 29 #include <sstream> |
1760 | 30 #include <string> |
31 | |
2095 | 32 #include <sys/types.h> |
33 | |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
34 namespace octave |
2095 | 35 { |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
36 class |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
37 OCTINTERP_API |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
38 pager_buf : public std::stringbuf |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
39 { |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
40 public: |
2095 | 41 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
42 pager_buf (void) : std::stringbuf (), diary_skip (0) { } |
2095 | 43 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
44 void flush_current_contents_to_diary (void); |
3477 | 45 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
46 void set_diary_skip (void); |
3756 | 47 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
48 protected: |
2095 | 49 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
50 int sync (void); |
3756 | 51 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
52 private: |
3756 | 53 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
54 size_t diary_skip; |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
55 }; |
2095 | 56 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
57 class |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
58 OCTINTERP_API |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
59 pager_stream : public std::ostream |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
60 { |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
61 protected: |
2095 | 62 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
63 pager_stream (void); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
64 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
65 public: |
2095 | 66 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
67 // No copying! |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
68 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
69 pager_stream (const pager_stream&) = delete; |
2095 | 70 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
71 pager_stream& operator = (const pager_stream&) = delete; |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
72 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
73 ~pager_stream (void); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
74 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
75 static void flush_current_contents_to_diary (void); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
76 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
77 static void set_diary_skip (void); |
2095 | 78 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
79 static std::ostream& stream (void); |
3477 | 80 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
81 static void reset (void); |
3756 | 82 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
83 private: |
2095 | 84 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
85 void do_flush_current_contents_to_diary (void); |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
86 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
87 void do_set_diary_skip (void); |
2095 | 88 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
89 void do_reset (void); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13266
diff
changeset
|
90 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
91 static pager_stream *instance; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13266
diff
changeset
|
92 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
93 static bool instance_ok (void); |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
94 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
95 static void cleanup_instance (void) { delete instance; instance = 0; } |
2095 | 96 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
97 pager_buf *pb; |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
98 }; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13266
diff
changeset
|
99 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
100 class |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
101 OCTINTERP_API |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
102 diary_buf : public std::stringbuf |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
103 { |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
104 public: |
1 | 105 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
106 diary_buf (void) : std::stringbuf () { } |
2095 | 107 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
108 protected: |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
109 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
110 int sync (void); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
111 }; |
2095 | 112 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
113 class |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
114 OCTINTERP_API |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
115 diary_stream : public std::ostream |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
116 { |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
117 protected: |
2095 | 118 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
119 diary_stream (void); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
120 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
121 public: |
2095 | 122 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
123 // No copying! |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
124 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
125 diary_stream (const diary_stream&) = delete; |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
126 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
127 diary_stream& operator = (const diary_stream&) = delete; |
2095 | 128 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
129 ~diary_stream (void); |
2095 | 130 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
131 static std::ostream& stream (void); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
132 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
133 static void reset (void); |
2095 | 134 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
135 private: |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
136 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
137 void do_reset (void); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
138 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
139 static diary_stream *instance; |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
140 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
141 static bool instance_ok (void); |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
142 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
143 static void cleanup_instance (void) { delete instance; instance = 0; } |
2095 | 144 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
145 diary_buf *db; |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
146 }; |
2095 | 147 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
148 extern OCTAVE_API void flush_stdout (void); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
149 } |
13266
c053740eb2aa
improve memory use for the pager and diary streams (bug #34431)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
150 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
151 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
2095 | 152 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
153 OCTAVE_DEPRECATED ("use 'octave::diary_buf' instead") |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
154 typedef octave::diary_buf octave_diary_buf; |
2095 | 155 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
156 OCTAVE_DEPRECATED ("use 'octave::diary_stream' instead") |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
157 typedef octave::diary_stream octave_diary_stream; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13266
diff
changeset
|
158 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
159 OCTAVE_DEPRECATED ("use 'octave::pager_buf' instead") |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
160 typedef octave::pager_buf octave_pager_buf; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13266
diff
changeset
|
161 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
162 OCTAVE_DEPRECATED ("use 'octave::pager_stream' instead") |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
163 typedef octave::pager_stream octave_pager_stream; |
2095 | 164 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
165 OCTAVE_DEPRECATED ("use 'octave::flush_stdout' instead") |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
166 static inline void |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
167 flush_octave_stdout (void) |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
168 { |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
169 return octave::flush_stdout (); |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
170 } |
2095 | 171 |
1 | 172 #endif |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
173 |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
174 #define octave_stdout (octave::pager_stream::stream ()) |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
175 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
176 #define octave_diary (octave::diary_stream::stream ()) |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
177 |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
178 #endif |
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
179 |