00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_procstream_h)
00025 #define octave_procstream_h 1
00026
00027 #include <iosfwd>
00028 #include <string>
00029
00030 #ifdef HAVE_SYS_TYPES_H
00031 #include <sys/types.h>
00032 #endif
00033
00034 #include "oct-procbuf.h"
00035
00036 class
00037 OCTINTERP_API
00038 procstreambase : virtual public std::ios
00039 {
00040 public:
00041
00042 procstreambase (void) { pb_init (); }
00043
00044 procstreambase (const std::string& name, int mode);
00045
00046 procstreambase (const char *name, int mode);
00047
00048 ~procstreambase (void) { close (); }
00049
00050 void open (const std::string& name, int mode)
00051 { open (name.c_str (), mode); }
00052
00053 void open (const char *name, int mode);
00054
00055 int is_open (void) const { return pb.is_open (); }
00056
00057 int close (void);
00058
00059 pid_t pid (void) const { return pb.pid (); }
00060
00061 int file_number (void) const { return pb.file_number (); }
00062
00063 private:
00064
00065 octave_procbuf pb;
00066
00067 void pb_init (void) { init (&pb); }
00068
00069 procstreambase (const procstreambase&);
00070
00071 procstreambase& operator = (const procstreambase&);
00072 };
00073
00074 class
00075 OCTINTERP_API
00076 iprocstream : public std::istream, public procstreambase
00077
00078 {
00079 public:
00080
00081 iprocstream (void) : std::istream (0), procstreambase () { }
00082
00083 iprocstream (const std::string& name, int mode = std::ios::in)
00084 : std::istream (0), procstreambase (name, mode) { }
00085
00086 iprocstream (const char *name, int mode = std::ios::in)
00087 : std::istream (0), procstreambase (name, mode) { }
00088
00089 ~iprocstream (void) { }
00090
00091 void open (const std::string& name, int mode = std::ios::in)
00092 { procstreambase::open (name, mode); }
00093
00094 void open (const char *name, int mode = std::ios::in)
00095 { procstreambase::open (name, mode); }
00096
00097 private:
00098
00099 iprocstream (const iprocstream&);
00100
00101 iprocstream& operator = (const iprocstream&);
00102 };
00103
00104 class
00105 OCTINTERP_API
00106 oprocstream : public std::ostream, public procstreambase
00107
00108 {
00109 public:
00110
00111 oprocstream (void) : std::ostream (0), procstreambase () { }
00112
00113 oprocstream (const std::string& name, int mode = std::ios::out)
00114 : std::ostream (0), procstreambase(name, mode) { }
00115
00116 oprocstream (const char *name, int mode = std::ios::out)
00117 : std::ostream (0), procstreambase(name, mode) { }
00118
00119 ~oprocstream (void) { }
00120
00121 void open (const std::string& name, int mode = std::ios::out)
00122 { procstreambase::open (name, mode); }
00123
00124 void open (const char *name, int mode = std::ios::out)
00125 { procstreambase::open (name, mode); }
00126
00127 private:
00128
00129 oprocstream (const oprocstream&);
00130
00131 oprocstream& operator = (const oprocstream&);
00132 };
00133
00134 class
00135 OCTINTERP_API
00136 procstream : public std::iostream, public procstreambase
00137
00138 {
00139 public:
00140
00141 procstream (void) : std::iostream (0), procstreambase () { }
00142
00143 procstream (const std::string& name, int mode)
00144 : std::iostream (0), procstreambase (name, mode) { }
00145
00146 procstream (const char *name, int mode)
00147 : std::iostream (0), procstreambase (name, mode) { }
00148
00149 ~procstream (void) { }
00150
00151 void open (const std::string& name, int mode)
00152 { procstreambase::open (name, mode); }
00153
00154 void open (const char *name, int mode)
00155 { procstreambase::open (name, mode); }
00156
00157 private:
00158
00159 procstream (const procstream&);
00160
00161 procstream& operator = (const procstream&);
00162 };
00163
00164 #endif
00165
00166
00167
00168
00169
00170