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