GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pager.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pager_h)
24 #define octave_pager_h 1
25 
26 #include "octave-config.h"
27 
28 #include <iosfwd>
29 #include <sstream>
30 #include <string>
31 
32 #include <sys/types.h>
33 
34 namespace octave
35 {
36  class
37  OCTINTERP_API
38  pager_buf : public std::stringbuf
39  {
40  public:
41 
42  pager_buf (void) : std::stringbuf (), diary_skip (0) { }
43 
44  void flush_current_contents_to_diary (void);
45 
46  void set_diary_skip (void);
47 
48  protected:
49 
50  int sync (void);
51 
52  private:
53 
54  size_t diary_skip;
55  };
56 
57  class
58  OCTINTERP_API
59  pager_stream : public std::ostream
60  {
61  protected:
62 
63  pager_stream (void);
64 
65  public:
66 
67  // No copying!
68 
69  pager_stream (const pager_stream&) = delete;
70 
71  pager_stream& operator = (const pager_stream&) = delete;
72 
73  ~pager_stream (void);
74 
75  static void flush_current_contents_to_diary (void);
76 
77  static void set_diary_skip (void);
78 
79  static std::ostream& stream (void);
80 
81  static void reset (void);
82 
83  private:
84 
85  void do_flush_current_contents_to_diary (void);
86 
87  void do_set_diary_skip (void);
88 
89  void do_reset (void);
90 
92 
93  static bool instance_ok (void);
94 
95  static void cleanup_instance (void) { delete instance; instance = nullptr; }
96 
98  };
99 
100  class
101  OCTINTERP_API
102  diary_buf : public std::stringbuf
103  {
104  public:
105 
106  diary_buf (void) : std::stringbuf () { }
107 
108  protected:
109 
110  int sync (void);
111  };
112 
113  class
114  OCTINTERP_API
115  diary_stream : public std::ostream
116  {
117  protected:
118 
119  diary_stream (void);
120 
121  public:
122 
123  // No copying!
124 
125  diary_stream (const diary_stream&) = delete;
126 
127  diary_stream& operator = (const diary_stream&) = delete;
128 
129  ~diary_stream (void);
130 
131  static std::ostream& stream (void);
132 
133  static void reset (void);
134 
135  private:
136 
137  void do_reset (void);
138 
140 
141  static bool instance_ok (void);
142 
143  static void cleanup_instance (void) { delete instance; instance = nullptr; }
144 
146  };
147 
148  extern OCTAVE_API void flush_stdout (void);
149 }
150 
151 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
152 
153 OCTAVE_DEPRECATED (4.4, "use 'octave::diary_buf' instead")
154 typedef octave::diary_buf octave_diary_buf;
155 
156 OCTAVE_DEPRECATED (4.4, "use 'octave::diary_stream' instead")
157 typedef octave::diary_stream octave_diary_stream;
158 
159 OCTAVE_DEPRECATED (4.4, "use 'octave::pager_buf' instead")
160 typedef octave::pager_buf octave_pager_buf;
161 
162 OCTAVE_DEPRECATED (4.4, "use 'octave::pager_stream' instead")
163 typedef octave::pager_stream octave_pager_stream;
164 
165 OCTAVE_DEPRECATED (4.4, "use 'octave::flush_stdout' instead")
166 static inline void
167 flush_octave_stdout (void)
168 {
169  return octave::flush_stdout ();
170 }
171 
172 #endif
173 
174 #define octave_stdout (octave::pager_stream::stream ())
175 
176 #define octave_diary (octave::diary_stream::stream ())
177 
178 #endif
void flush_stdout(void)
Definition: pager.cc:464
STL namespace.
static diary_stream * instance
Definition: pager.h:139
static void cleanup_instance(void)
Definition: pager.h:143
diary_buf(void)
Definition: pager.h:106
static void cleanup_instance(void)
Definition: pager.h:95
pager_buf(void)
Definition: pager.h:42
diary_buf * db
Definition: pager.h:145
static pager_stream * instance
Definition: pager.h:91
size_t diary_skip
Definition: pager.h:54
pager_buf * pb
Definition: pager.h:97