GNU Octave  4.2.1
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
procstream.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2017 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_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
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
76 iprocstream : public std::istream, public procstreambase
77 // iprocstream : public procstreambase, public std::istream
78 {
79 public:
80 
81  iprocstream (void) : std::istream (0), procstreambase () { }
82 
83  iprocstream (const std::string& name, int mode = std::ios::in)
84  : std::istream (0), procstreambase (name, mode) { }
85 
86  iprocstream (const char *name, int mode = std::ios::in)
87  : std::istream (0), procstreambase (name, mode) { }
88 
89  ~iprocstream (void) { }
90 
91  void open (const std::string& name, int mode = std::ios::in)
92  { procstreambase::open (name, mode); }
93 
94  void open (const char *name, int mode = std::ios::in)
95  { procstreambase::open (name, mode); }
96 
97 private:
98 
99  iprocstream (const iprocstream&);
100 
102 };
103 
104 class
106 oprocstream : public std::ostream, public procstreambase
107 // oprocstream : public procstreambase, public std::ostream
108 {
109 public:
110 
111  oprocstream (void) : std::ostream (0), procstreambase () { }
112 
113  oprocstream (const std::string& name, int mode = std::ios::out)
114  : std::ostream (0), procstreambase (name, mode) { }
115 
116  oprocstream (const char *name, int mode = std::ios::out)
117  : std::ostream (0), procstreambase (name, mode) { }
118 
119  ~oprocstream (void) { }
120 
121  void open (const std::string& name, int mode = std::ios::out)
122  { procstreambase::open (name, mode); }
123 
124  void open (const char *name, int mode = std::ios::out)
125  { procstreambase::open (name, mode); }
126 
127 private:
128 
129  oprocstream (const oprocstream&);
130 
132 };
133 
134 class
136 procstream : public std::iostream, public procstreambase
137 // procstream : public procstreambase, public std::iostream
138 {
139 public:
140 
141  procstream (void) : std::iostream (0), procstreambase () { }
142 
144  : std::iostream (0), procstreambase (name, mode) { }
145 
146  procstream (const char *name, int mode)
147  : std::iostream (0), procstreambase (name, mode) { }
148 
149  ~procstream (void) { }
150 
151  void open (const std::string& name, int mode)
152  { procstreambase::open (name, mode); }
153 
154  void open (const char *name, int mode)
155  { procstreambase::open (name, 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:6386
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
int is_open(void) const
Definition: procstream.h:55
~oprocstream(void)
Definition: procstream.h:119
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
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
~iprocstream(void)
Definition: procstream.h:89
#define OCTINTERP_API
Definition: mexproto.h:69
void open(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:91
~procstream(void)
Definition: procstream.h:149
pid_t pid(void) const
Definition: procstream.h:59
intNDArray & operator=(const intNDArray< T > &a)
Definition: intNDArray.h:58
void pb_init(void)
Definition: procstream.h:67
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
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:854
void open(const char *name, int mode)
Definition: procstream.h:154
int file_number(void) const
Definition: procstream.h:61
iprocstream(const std::string &name, int mode=std::ios::in)
Definition: procstream.h:83