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_octave_iostream_h)
00025 #define octave_octave_iostream_h 1
00026
00027 #include <iosfwd>
00028
00029 #include "oct-stream.h"
00030
00031 class
00032 octave_base_iostream : public octave_base_stream
00033 {
00034 public:
00035
00036 octave_base_iostream (const std::string& n = std::string (),
00037 std::ios::openmode m = std::ios::in|std::ios::out,
00038 oct_mach_info::float_format ff
00039 = oct_mach_info::native_float_format ())
00040 : octave_base_stream (m, ff), nm (n) { }
00041
00042
00043
00044 int seek (long offset, int origin);
00045
00046
00047
00048 long tell (void);
00049
00050
00051
00052 bool eof (void) const;
00053
00054
00055
00056 std::string name (void) const { return nm; }
00057
00058 protected:
00059
00060 ~octave_base_iostream (void) { }
00061
00062 void invalid_operation (void) const;
00063
00064 private:
00065
00066 std::string nm;
00067
00068 virtual const char *stream_type (void) const = 0;
00069
00070
00071
00072 octave_base_iostream (const octave_base_iostream&);
00073
00074 octave_base_iostream& operator = (const octave_base_iostream&);
00075 };
00076
00077 class
00078 octave_istream : public octave_base_iostream
00079 {
00080 public:
00081
00082 octave_istream (std::istream *arg = 0, const std::string& n = std::string ())
00083 : octave_base_iostream (n, std::ios::in,
00084 oct_mach_info::native_float_format ()),
00085 is (arg)
00086 { }
00087
00088 static octave_stream
00089 create (std::istream *arg = 0, const std::string& n = std::string ());
00090
00091
00092
00093 bool eof (void) const;
00094
00095 std::istream *input_stream (void) { return is; }
00096
00097 std::ostream *output_stream (void) { return 0; }
00098
00099 protected:
00100
00101 ~octave_istream (void) { }
00102
00103 private:
00104
00105 std::istream *is;
00106
00107 const char *stream_type (void) const { return "octave_istream"; }
00108
00109
00110
00111 octave_istream (const octave_istream&);
00112
00113 octave_istream& operator = (const octave_istream&);
00114 };
00115
00116 class
00117 octave_ostream : public octave_base_iostream
00118 {
00119 public:
00120
00121 octave_ostream (std::ostream *arg, const std::string& n = std::string ())
00122 : octave_base_iostream (n, std::ios::out,
00123 oct_mach_info::native_float_format ()),
00124 os (arg)
00125 { }
00126
00127 static octave_stream
00128 create (std::ostream *arg, const std::string& n = std::string ());
00129
00130
00131
00132 bool eof (void) const;
00133
00134 std::istream *input_stream (void) { return 0; }
00135
00136 std::ostream *output_stream (void) { return os; }
00137
00138 protected:
00139
00140 ~octave_ostream (void) { }
00141
00142 private:
00143
00144 std::ostream *os;
00145
00146 const char *stream_type (void) const { return "octave_ostream"; }
00147
00148
00149
00150 octave_ostream (const octave_ostream&);
00151
00152 octave_ostream& operator = (const octave_ostream&);
00153 };
00154
00155 #endif
00156
00157
00158
00159
00160
00161