GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
procstream.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_procstream_h)
27#define octave_procstream_h 1
28
29#include "octave-config.h"
30
31#include <iosfwd>
32#include <string>
33
34#include <sys/types.h>
35
36#include "oct-procbuf.h"
37
38OCTAVE_NAMESPACE_BEGIN
39
40class
41OCTINTERP_API
42procstreambase : virtual public std::ios
43{
44public:
45
46 procstreambase (void) : m_pb () { pb_init (); }
47
48 procstreambase (const std::string& name, int mode);
49
50 procstreambase (const char *name, int mode);
51
52 ~procstreambase (void) { close (); }
53
54 void open (const std::string& name, int mode)
55 {
56 open (name.c_str (), mode);
57 }
58
59 void open (const char *name, int mode);
60
61 int is_open (void) const { return m_pb.is_open (); }
62
63 int close (void);
64
65 pid_t pid (void) const { return m_pb.pid (); }
66
67 int file_number (void) const { return m_pb.file_number (); }
68
69private:
70
72
73 void pb_init (void)
74 {
75 // Explicit initialization of the std::ios object is needed.
76 // FIXME: is there a better way to organize these classes?
77 init (&m_pb);
78 }
79
81
82 procstreambase& operator = (const procstreambase&);
83};
84
85class
86OCTINTERP_API
87iprocstream : public std::istream, public procstreambase
88{
89public:
90
91 iprocstream (void) : std::istream (nullptr), procstreambase () { }
92
93 iprocstream (const std::string& name, int mode = std::ios::in)
94 : std::istream (nullptr), procstreambase (name, mode)
95 { }
96
97 iprocstream (const char *name, int mode = std::ios::in)
98 : std::istream (nullptr), procstreambase (name, mode)
99 { }
100
101 ~iprocstream (void) = default;
102
103 void open (const std::string& name, int mode = std::ios::in)
104 {
106 }
107
108 void open (const char *name, int mode = std::ios::in)
109 {
111 }
112
113private:
114
116
117 iprocstream& operator = (const iprocstream&);
118};
119
120class
121OCTINTERP_API
122oprocstream : public std::ostream, public procstreambase
123{
124public:
125
126 oprocstream (void) : std::ostream (nullptr), procstreambase () { }
127
128 oprocstream (const std::string& name, int mode = std::ios::out)
129 : std::ostream (nullptr), procstreambase (name, mode) { }
130
131 oprocstream (const char *name, int mode = std::ios::out)
132 : std::ostream (nullptr), procstreambase (name, mode) { }
133
134 ~oprocstream (void) = default;
135
136 void open (const std::string& name, int mode = std::ios::out)
137 {
139 }
140
141 void open (const char *name, int mode = std::ios::out)
142 {
144 }
145
146private:
147
149
150 oprocstream& operator = (const oprocstream&);
151};
152
153class
154OCTINTERP_API
155procstream : public std::iostream, public procstreambase
156{
157public:
158
159 procstream (void) : std::iostream (nullptr), procstreambase () { }
160
161 procstream (const std::string& name, int mode)
162 : std::iostream (nullptr), procstreambase (name, mode)
163 { }
164
165 procstream (const char *name, int mode)
166 : std::iostream (nullptr), procstreambase (name, mode)
167 { }
168
169 ~procstream (void) = default;
170
171 void open (const std::string& name, int mode)
172 {
174 }
175
176 void open (const char *name, int mode)
177 {
179 }
180
181private:
182
184
185 procstream& operator = (const procstream&);
186};
187
188OCTAVE_NAMESPACE_END
189
190#if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
191
192OCTAVE_DEPRECATED (7, "use 'octave::procstreambase' instead")
194
195OCTAVE_DEPRECATED (7, "use 'octave::iprocstream' instead")
197
198OCTAVE_DEPRECATED (7, "use 'octave::oprocstream' instead")
200
201OCTAVE_DEPRECATED (7, "use 'octave::procstream' instead")
203
204#endif
205
206#endif
void open(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:103
iprocstream(const iprocstream &)
iprocstream(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:93
iprocstream(void)
Definition: procstream.h:91
iprocstream(const char *name, int mode=std::ios::in)
Definition: procstream.h:97
void open(const char *name, int mode=std::ios::in)
Definition: procstream.h:108
~iprocstream(void)=default
oprocstream(const std::string &name, int mode=std::ios::out)
Definition: procstream.h:128
oprocstream(const char *name, int mode=std::ios::out)
Definition: procstream.h:131
void open(const char *name, int mode=std::ios::out)
Definition: procstream.h:141
~oprocstream(void)=default
void open(const std::string &name, int mode=std::ios::out)
Definition: procstream.h:136
oprocstream(void)
Definition: procstream.h:126
oprocstream(const oprocstream &)
procstream(const procstream &)
procstream(const char *name, int mode)
Definition: procstream.h:165
procstream(const std::string &name, int mode)
Definition: procstream.h:161
~procstream(void)=default
void open(const char *name, int mode)
Definition: procstream.h:176
void open(const std::string &name, int mode)
Definition: procstream.h:171
procstream(void)
Definition: procstream.h:159
void open(const std::string &name, int mode)
Definition: procstream.h:54
int file_number(void) const
Definition: procstream.h:67
void pb_init(void)
Definition: procstream.h:73
procbuf m_pb
Definition: procstream.h:71
~procstreambase(void)
Definition: procstream.h:52
pid_t pid(void) const
Definition: procstream.h:65
int is_open(void) const
Definition: procstream.h:61
procstreambase(const procstreambase &)
procstreambase(void)
Definition: procstream.h:46
QString name
STL namespace.