Mercurial > hg > octave-lyh
annotate src/oct-strstrm.h @ 11422:3cae59b4c0f7
Improve docstrings for functions which emulate operators.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 28 Dec 2010 17:43:43 -0800 |
parents | f3b65e1ae355 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
2081 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
2081 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2081 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2081 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_octave_strstream_h) | |
25 #define octave_octave_strstream_h 1 | |
26 | |
2445 | 27 #include <string> |
5765 | 28 #include <sstream> |
4051 | 29 |
2081 | 30 #include "oct-stream.h" |
31 | |
32 class | |
33 octave_base_strstream : public octave_base_stream | |
34 { | |
35 public: | |
36 | |
4587 | 37 octave_base_strstream (std::ios::openmode m = std::ios::out, |
10313 | 38 oct_mach_info::float_format ff |
39 = oct_mach_info::native_float_format ()) | |
4587 | 40 : octave_base_stream (m, ff) { } |
2081 | 41 |
42 // Position a stream at OFFSET relative to ORIGIN. | |
43 | |
4933 | 44 int seek (long, int); |
2081 | 45 |
46 // Return current stream position. | |
47 | |
9795
3ccd3a03944c
Fix fourth argument from sscanf
David Grundberg <davidg@cs.umu.se>
parents:
7017
diff
changeset
|
48 virtual long tell (void); |
2081 | 49 |
50 // The name of the file. | |
51 | |
3523 | 52 std::string name (void) const { return std::string (); } |
2081 | 53 |
3523 | 54 virtual std::streambuf *rdbuf (void) = 0; |
2081 | 55 |
56 virtual bool bad (void) const = 0; | |
57 | |
58 virtual void clear (void) = 0; | |
59 | |
3340 | 60 protected: |
61 | |
62 ~octave_base_strstream (void) { } | |
63 | |
2081 | 64 private: |
65 | |
66 // No copying! | |
67 | |
68 octave_base_strstream (const octave_base_strstream&); | |
69 | |
70 octave_base_strstream& operator = (const octave_base_strstream&); | |
71 }; | |
72 | |
73 class | |
74 octave_istrstream : public octave_base_strstream | |
75 { | |
76 public: | |
77 | |
78 octave_istrstream (const char *data, | |
10313 | 79 std::ios::openmode arg_md = std::ios::out, |
80 oct_mach_info::float_format ff | |
81 = oct_mach_info::native_float_format ()) | |
4587 | 82 : octave_base_strstream (arg_md, ff), is (data) { } |
2081 | 83 |
3523 | 84 octave_istrstream (const std::string& data, |
10313 | 85 std::ios::openmode arg_md = std::ios::out, |
86 oct_mach_info::float_format ff | |
87 = oct_mach_info::native_float_format ()) | |
4587 | 88 : octave_base_strstream (arg_md, ff), is (data.c_str ()) { } |
2081 | 89 |
3340 | 90 static octave_stream |
3538 | 91 create (const char *data, std::ios::openmode arg_md = std::ios::out, |
10313 | 92 oct_mach_info::float_format ff |
93 = oct_mach_info::native_float_format ()); | |
3340 | 94 |
95 static octave_stream | |
3538 | 96 create (const std::string& data, std::ios::openmode arg_md = std::ios::out, |
10313 | 97 oct_mach_info::float_format ff |
98 = oct_mach_info::native_float_format ()); | |
2081 | 99 |
100 // Return non-zero if EOF has been reached on this stream. | |
101 | |
102 bool eof (void) const { return is.eof (); } | |
103 | |
3523 | 104 std::istream *input_stream (void) { return &is; } |
2081 | 105 |
3523 | 106 std::ostream *output_stream (void) { return 0; } |
2081 | 107 |
9795
3ccd3a03944c
Fix fourth argument from sscanf
David Grundberg <davidg@cs.umu.se>
parents:
7017
diff
changeset
|
108 long tell (void) { return is.tellg (); } |
3ccd3a03944c
Fix fourth argument from sscanf
David Grundberg <davidg@cs.umu.se>
parents:
7017
diff
changeset
|
109 |
3523 | 110 std::streambuf *rdbuf (void) { return is ? is.rdbuf () : 0; } |
2081 | 111 |
112 bool bad (void) const { return is.bad (); } | |
113 | |
114 void clear (void) { is.clear (); } | |
115 | |
3340 | 116 protected: |
117 | |
118 ~octave_istrstream (void) { } | |
119 | |
2081 | 120 private: |
121 | |
5765 | 122 std::istringstream is; |
2081 | 123 |
124 // No copying! | |
125 | |
126 octave_istrstream (const octave_istrstream&); | |
127 | |
128 octave_istrstream& operator = (const octave_istrstream&); | |
129 }; | |
130 | |
131 class | |
132 octave_ostrstream : public octave_base_strstream | |
133 { | |
134 public: | |
135 | |
3538 | 136 octave_ostrstream (std::ios::openmode arg_md = std::ios::out, |
10313 | 137 oct_mach_info::float_format ff |
138 = oct_mach_info::native_float_format ()) | |
4587 | 139 : octave_base_strstream (arg_md, ff) { } |
2081 | 140 |
3340 | 141 static octave_stream |
3538 | 142 create (std::ios::openmode arg_md = std::ios::out, |
10313 | 143 oct_mach_info::float_format ff |
144 = oct_mach_info::native_float_format ()); | |
2081 | 145 |
146 // Return non-zero if EOF has been reached on this stream. | |
147 | |
148 bool eof (void) const { return os.eof (); } | |
149 | |
3523 | 150 std::istream *input_stream (void) { return 0; } |
2081 | 151 |
3523 | 152 std::ostream *output_stream (void) { return &os; } |
2081 | 153 |
5765 | 154 std::string str (void) { return os.str (); } |
2081 | 155 |
3523 | 156 std::streambuf *rdbuf (void) { return os ? os.rdbuf () : 0; } |
2081 | 157 |
158 bool bad (void) const { return os.bad (); } | |
159 | |
160 void clear (void) { os.clear (); } | |
161 | |
3340 | 162 protected: |
163 | |
164 ~octave_ostrstream (void) { } | |
165 | |
2081 | 166 private: |
167 | |
5765 | 168 std::ostringstream os; |
2081 | 169 |
170 // No copying! | |
171 | |
172 octave_ostrstream (const octave_ostrstream&); | |
173 | |
174 octave_ostrstream& operator = (const octave_ostrstream&); | |
175 }; | |
176 | |
177 #endif |