comparison src/oct-strstrm.h @ 3340:585a8809fd9b

[project @ 1999-11-05 07:02:30 by jwe]
author jwe
date Fri, 05 Nov 1999 07:02:36 +0000
parents 8b262e771614
children d14c483b3c12
comparison
equal deleted inserted replaced
3339:f8b4692eb51c 3340:585a8809fd9b
37 octave_base_strstream (ios::openmode arg_md = ios::out, 37 octave_base_strstream (ios::openmode arg_md = ios::out,
38 oct_mach_info::float_format flt_fmt = 38 oct_mach_info::float_format flt_fmt =
39 oct_mach_info::native) 39 oct_mach_info::native)
40 : octave_base_stream (arg_md, flt_fmt) { } 40 : octave_base_stream (arg_md, flt_fmt) { }
41 41
42 ~octave_base_strstream (void) { }
43
44 // Position a stream at OFFSET relative to ORIGIN. 42 // Position a stream at OFFSET relative to ORIGIN.
45 43
46 int seek (streamoff offset, ios::seek_dir origin); 44 int seek (streamoff offset, ios::seek_dir origin);
47 45
48 // Return current stream position. 46 // Return current stream position.
49 47
50 long tell (void) const; 48 long tell (void) const;
51 49
52 // The name of the file. 50 // The name of the file.
53 51
54 string name (void) { return string (); } 52 string name (void) const { return string (); }
55 53
56 virtual streambuf *rdbuf (void) = 0; 54 virtual streambuf *rdbuf (void) = 0;
57 55
58 virtual bool bad (void) const = 0; 56 virtual bool bad (void) const = 0;
59 57
60 virtual void clear (void) = 0; 58 virtual void clear (void) = 0;
59
60 protected:
61
62 ~octave_base_strstream (void) { }
61 63
62 private: 64 private:
63 65
64 // No copying! 66 // No copying!
65 67
83 ios::openmode arg_md = ios::out, 85 ios::openmode arg_md = ios::out,
84 oct_mach_info::float_format flt_fmt = 86 oct_mach_info::float_format flt_fmt =
85 oct_mach_info::native) 87 oct_mach_info::native)
86 : octave_base_strstream (arg_md, flt_fmt), is (data.c_str ()) { } 88 : octave_base_strstream (arg_md, flt_fmt), is (data.c_str ()) { }
87 89
88 ~octave_istrstream (void) { } 90 static octave_stream
91 create (const char *data, ios::openmode arg_md = ios::out,
92 oct_mach_info::float_format flt_fmt = oct_mach_info::native);
93
94 static octave_stream
95 create (const string& data, ios::openmode arg_md = ios::out,
96 oct_mach_info::float_format flt_fmt = oct_mach_info::native);
89 97
90 // Return non-zero if EOF has been reached on this stream. 98 // Return non-zero if EOF has been reached on this stream.
91 99
92 bool eof (void) const { return is.eof (); } 100 bool eof (void) const { return is.eof (); }
93 101
98 streambuf *rdbuf (void) { return is ? is.rdbuf () : 0; } 106 streambuf *rdbuf (void) { return is ? is.rdbuf () : 0; }
99 107
100 bool bad (void) const { return is.bad (); } 108 bool bad (void) const { return is.bad (); }
101 109
102 void clear (void) { is.clear (); } 110 void clear (void) { is.clear (); }
111
112 protected:
113
114 ~octave_istrstream (void) { }
103 115
104 private: 116 private:
105 117
106 istrstream is; 118 istrstream is;
107 119
120 octave_ostrstream (ios::openmode arg_md = ios::out, 132 octave_ostrstream (ios::openmode arg_md = ios::out,
121 oct_mach_info::float_format flt_fmt = 133 oct_mach_info::float_format flt_fmt =
122 oct_mach_info::native) 134 oct_mach_info::native)
123 : octave_base_strstream (arg_md, flt_fmt) { } 135 : octave_base_strstream (arg_md, flt_fmt) { }
124 136
125 ~octave_ostrstream (void) { } 137 static octave_stream
138 create (ios::openmode arg_md = ios::out,
139 oct_mach_info::float_format flt_fmt = oct_mach_info::native);
126 140
127 // Return non-zero if EOF has been reached on this stream. 141 // Return non-zero if EOF has been reached on this stream.
128 142
129 bool eof (void) const { return os.eof (); } 143 bool eof (void) const { return os.eof (); }
130 144
131 istream *input_stream (void) { return 0; } 145 istream *input_stream (void) { return 0; }
132 146
133 ostream *output_stream (void) { return &os; } 147 ostream *output_stream (void) { return &os; }
134 148
135 char *str (void) 149 string str (void)
136 { 150 {
137 os << ends; 151 os << ends;
138 return os.str (); 152 char *tmp = os.str ();
153 string retval = tmp;
154 delete [] tmp;
155 return retval;
139 } 156 }
140 157
141 streambuf *rdbuf (void) { return os ? os.rdbuf () : 0; } 158 streambuf *rdbuf (void) { return os ? os.rdbuf () : 0; }
142 159
143 bool bad (void) const { return os.bad (); } 160 bool bad (void) const { return os.bad (); }
144 161
145 void clear (void) { os.clear (); } 162 void clear (void) { os.clear (); }
163
164 protected:
165
166 ~octave_ostrstream (void) { }
146 167
147 private: 168 private:
148 169
149 ostrstream os; 170 ostrstream os;
150 171