GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pager.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pager_h)
24 #define octave_pager_h 1
25 
26 #include <iosfwd>
27 #include <sstream>
28 #include <string>
29 
30 #include <sys/types.h>
31 
32 class
34 octave_pager_buf : public std::stringbuf
35 {
36 public:
37 
38  octave_pager_buf (void) : std::stringbuf (), diary_skip (0) { }
39 
40  void flush_current_contents_to_diary (void);
41 
42  void set_diary_skip (void);
43 
44 protected:
45 
46  int sync (void);
47 
48 private:
49 
50  size_t diary_skip;
51 };
52 
53 class
55 octave_pager_stream : public std::ostream
56 {
57 protected:
58 
59  octave_pager_stream (void);
60 
61 public:
62 
63  ~octave_pager_stream (void);
64 
65  static void flush_current_contents_to_diary (void);
66 
67  static void set_diary_skip (void);
68 
69  static std::ostream& stream (void);
70 
71  static void reset (void);
72 
73 private:
74 
75  void do_flush_current_contents_to_diary (void);
76 
77  void do_set_diary_skip (void);
78 
79  void do_reset (void);
80 
82 
83  static bool instance_ok (void);
84 
85  static void cleanup_instance (void) { delete instance; instance = 0; }
86 
88 
89  // No copying!
90 
92 
94 };
95 
96 class
98 octave_diary_buf : public std::stringbuf
99 {
100 public:
101 
102  octave_diary_buf (void) : std::stringbuf () { }
103 
104 protected:
105 
106  int sync (void);
107 };
108 
109 class
111 octave_diary_stream : public std::ostream
112 {
113 protected:
114 
115  octave_diary_stream (void);
116 
117 public:
118 
119  ~octave_diary_stream (void);
120 
121  static std::ostream& stream (void);
122 
123  static void reset (void);
124 
125 private:
126 
127  void do_reset (void);
128 
130 
131  static bool instance_ok (void);
132 
133  static void cleanup_instance (void) { delete instance; instance = 0; }
134 
136 
137  // No copying!
138 
140 
142 };
143 
144 #define octave_stdout (octave_pager_stream::stream ())
145 
146 #define octave_diary (octave_diary_stream::stream ())
147 
148 extern OCTINTERP_API void flush_octave_stdout (void);
149 
150 #endif