GNU Octave  4.4.1
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-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_procstream_h)
24 #define octave_procstream_h 1
25 
26 #include "octave-config.h"
27 
28 #include <istream>
29 #include <ostream>
30 #include <string>
31 
32 #include <sys/types.h>
33 
34 #include "oct-procbuf.h"
35 
36 class
37 OCTINTERP_API
38 procstreambase : virtual public std::ios
39 {
40 public:
41 
42  procstreambase (void) : pb () { pb_init (); }
43 
44  procstreambase (const std::string& name, int mode);
45 
46  procstreambase (const char *name, int mode);
47 
48  ~procstreambase (void) { close (); }
49 
50  void open (const std::string& name, int mode)
51  { open (name.c_str (), mode); }
52 
53  void open (const char *name, int mode);
54 
55  int is_open (void) const { return pb.is_open (); }
56 
57  int close (void);
58 
59  pid_t pid (void) const { return pb.pid (); }
60 
61  int file_number (void) const { return pb.file_number (); }
62 
63 private:
64 
66 
67  void pb_init (void) { init (&pb); }
68 
70 
72 };
73 
74 class
75 OCTINTERP_API
76 iprocstream : public std::istream, public procstreambase
77 // iprocstream : public procstreambase, public std::istream
78 {
79 public:
80 
81  iprocstream (void) : std::istream (nullptr), procstreambase () { }
82 
83  iprocstream (const std::string& name, int mode = std::ios::in)
84  : std::istream (nullptr), procstreambase (name, mode) { }
85 
86  iprocstream (const char *name, int mode = std::ios::in)
87  : std::istream (nullptr), procstreambase (name, mode) { }
88 
89  ~iprocstream (void) = default;
90 
91  void open (const std::string& name, int mode = std::ios::in)
93 
94  void open (const char *name, int mode = std::ios::in)
96 
97 private:
98 
99  iprocstream (const iprocstream&);
100 
102 };
103 
104 class
105 OCTINTERP_API
106 oprocstream : public std::ostream, public procstreambase
107 // oprocstream : public procstreambase, public std::ostream
108 {
109 public:
110 
111  oprocstream (void) : std::ostream (nullptr), procstreambase () { }
112 
113  oprocstream (const std::string& name, int mode = std::ios::out)
114  : std::ostream (nullptr), procstreambase (name, mode) { }
115 
116  oprocstream (const char *name, int mode = std::ios::out)
117  : std::ostream (nullptr), procstreambase (name, mode) { }
118 
119  ~oprocstream (void) = default;
120 
121  void open (const std::string& name, int mode = std::ios::out)
123 
124  void open (const char *name, int mode = std::ios::out)
126 
127 private:
128 
129  oprocstream (const oprocstream&);
130 
132 };
133 
134 class
135 OCTINTERP_API
136 procstream : public std::iostream, public procstreambase
137 // procstream : public procstreambase, public std::iostream
138 {
139 public:
140 
141  procstream (void) : std::iostream (nullptr), procstreambase () { }
142 
144  : std::iostream (nullptr), procstreambase (name, mode) { }
145 
146  procstream (const char *name, int mode)
147  : std::iostream (nullptr), procstreambase (name, mode) { }
148 
149  ~procstream (void) = default;
150 
151  void open (const std::string& name, int mode)
153 
154  void open (const char *name, int mode)
156 
157 private:
158 
159  procstream (const procstream&);
160 
162 };
163 
164 #endif
procstream(void)
Definition: procstream.h:141
oprocstream(void)
Definition: procstream.h:111
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6348
oprocstream(const char *name, int mode=std::ios::out)
Definition: procstream.h:116
STL namespace.
void open(const std::string &name, int mode)
Definition: procstream.h:50
void open(const std::string &name, int mode=std::ios::out)
Definition: procstream.h:121
iprocstream(void)
Definition: procstream.h:81
~procstreambase(void)
Definition: procstream.h:48
void open(const std::string &name, int mode)
Definition: procstream.h:151
pid_t pid(void) const
Definition: procstream.h:59
int is_open(void) const
Definition: procstream.h:55
oprocstream(const std::string &name, int mode=std::ios::out)
Definition: procstream.h:113
procstream(const std::string &name, int mode)
Definition: procstream.h:143
nd deftypefn *std::string name
Definition: sysdep.cc:647
void open(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:91
void pb_init(void)
Definition: procstream.h:67
int file_number(void) const
Definition: procstream.h:61
iprocstream(const char *name, int mode=std::ios::in)
Definition: procstream.h:86
procstream(const char *name, int mode)
Definition: procstream.h:146
procstreambase(void)
Definition: procstream.h:42
void open(const char *name, int mode=std::ios::in)
Definition: procstream.h:94
intNDArray & operator=(const intNDArray< T > &a)
Definition: intNDArray.h:59
octave_procbuf pb
Definition: procstream.h:65
void open(const char *name, int mode=std::ios::out)
Definition: procstream.h:124
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
void open(const char *name, int mode)
Definition: procstream.h:154
iprocstream(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:83