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