misc fixes of ctor signatures
[wxWidgets.git] / interface / wx / datstrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: datstrm.h
3 // Purpose: interface of wxDataInputStream and wxDataOutputStream
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxDataOutputStream
11
12 This class provides functions that write binary data types in a portable
13 way. Data can be written in either big-endian or little-endian format,
14 little-endian being the default on all architectures.
15
16 If you want to write data to text files (or streams) use wxTextOutputStream
17 instead.
18
19 The "<<" operator is overloaded and you can use this class like a standard
20 C++ iostream. See wxDataInputStream for its usage and caveats.
21
22 @library{wxbase}
23 @category{streams}
24
25 @see wxDataInputStream
26 */
27 class wxDataOutputStream
28 {
29 public:
30 /**
31 Constructs a datastream object from an output stream.
32 Only write methods will be available.
33
34 @param stream
35 The output stream.
36 */
37 wxDataOutputStream(wxOutputStream& stream,
38 const wxMBConv& conv = wxConvAuto());
39
40 /**
41 Constructs a datastream object from an output stream. Only write
42 methods will be available. This constructor is only available in
43 Unicode builds of wxWidgets.
44
45 @param stream
46 The output stream.
47 @param conv
48 Charset conversion object object used to encoding Unicode strings
49 before writing them to the stream in Unicode mode (see
50 WriteString() for a detailed description). Note that you must not
51 destroy @a conv before you destroy this wxDataOutputStream
52 instance! It is recommended to use the default value (UTF-8).
53 */
54 wxDataOutputStream(wxOutputStream& stream,
55 const wxMBConv& conv = wxConvAuto());
56
57 /**
58 Destroys the wxDataOutputStream object.
59 */
60 ~wxDataOutputStream();
61
62 /**
63 If @a be_order is @true, all data will be written in big-endian order,
64 e.g. for reading on a Sparc or from Java-Streams (which always use
65 big-endian order), otherwise data will be written in little-endian
66 order.
67 */
68 void BigEndianOrdered(bool be_order);
69
70 /**
71 Writes the single byte @a i8 to the stream.
72 */
73 void Write8(wxUint8 i8);
74 /**
75 Writes an array of bytes to the stream. The amount of bytes to write is
76 specified with the @a size variable.
77 */
78 void Write8(const wxUint8* buffer, size_t size);
79
80 /**
81 Writes the 16 bit unsigned integer @a i16 to the stream.
82 */
83 void Write16(wxUint16 i16);
84 /**
85 Writes an array of 16 bit unsigned integer to the stream. The amount of
86 16 bit unsigned integer to write is specified with the @a size variable.
87 */
88 void Write16(const wxUint16* buffer, size_t size);
89
90 /**
91 Writes the 32 bit unsigned integer @a i32 to the stream.
92 */
93 void Write32(wxUint32 i32);
94 /**
95 Writes an array of 32 bit unsigned integer to the stream. The amount of
96 32 bit unsigned integer to write is specified with the @a size variable.
97 */
98 void Write32(const wxUint32* buffer, size_t size);
99
100 /**
101 Writes the 64 bit unsigned integer @a i64 to the stream.
102 */
103 void Write64(wxUint64 i64);
104 /**
105 Writes an array of 64 bit unsigned integer to the stream. The amount of
106 64 bit unsigned integer to write is specified with the @a size variable.
107 */
108 void Write64(const wxUint64* buffer, size_t size);
109
110 /**
111 Writes the double @a f to the stream using the IEEE format.
112 */
113 void WriteDouble(double f);
114 /**
115 Writes an array of double to the stream. The amount of double to write is
116 specified with the @a size variable.
117 */
118 void WriteDouble(const double* buffer, size_t size);
119
120 /**
121 Writes @a string to the stream. Actually, this method writes the size
122 of the string before writing @a string itself.
123
124 In ANSI build of wxWidgets, the string is written to the stream in
125 exactly same way it is represented in memory. In Unicode build,
126 however, the string is first converted to multibyte representation with
127 @e conv object passed to stream's constructor (consequently, ANSI
128 applications can read data written by Unicode application, as long as
129 they agree on encoding) and this representation is written to the
130 stream. UTF-8 is used by default.
131 */
132 void WriteString(const wxString& string);
133 };
134
135
136
137 /**
138 @class wxDataInputStream
139
140 This class provides functions that read binary data types in a portable
141 way. Data can be read in either big-endian or little-endian format,
142 little-endian being the default on all architectures.
143
144 If you want to read data from text files (or streams) use wxTextInputStream
145 instead.
146
147 The ">>" operator is overloaded and you can use this class like a standard
148 C++ iostream. Note, however, that the arguments are the fixed size types
149 wxUint32, wxInt32 etc and on a typical 32-bit computer, none of these match
150 to the "long" type (wxInt32 is defined as signed int on 32-bit
151 architectures) so that you cannot use long. To avoid problems (here and
152 elsewhere), make use of the wxInt32, wxUint32, etc types.
153
154 For example:
155
156 @code
157 wxFileInputStream input( "mytext.dat" );
158 wxDataInputStream store( input );
159 wxUint8 i1;
160 float f2;
161 wxString line;
162
163 store >> i1; // read a 8 bit integer.
164 store >> i1 >> f2; // read a 8 bit integer followed by float.
165 store >> line; // read a text line
166 @endcode
167
168 @library{wxbase}
169 @category{streams}
170
171 @see wxDataOutputStream
172 */
173 class wxDataInputStream
174 {
175 public:
176 /**
177 Constructs a datastream object from an input stream.
178 Only read methods will be available.
179
180 @param stream
181 The input stream.
182 */
183 wxDataInputStream(wxInputStream& stream,
184 const wxMBConv& conv = wxConvAuto());
185
186 /**
187 Constructs a datastream object from an input stream. Only read methods
188 will be available. This constructor is only available in Unicode builds
189 of wxWidgets.
190
191 @param stream
192 The input stream.
193 @param conv
194 Charset conversion object object used to decode strings in Unicode
195 mode (see ReadString() for a detailed description). Note that you
196 must not destroy @a conv before you destroy this wxDataInputStream
197 instance!
198 */
199 wxDataInputStream(wxInputStream& stream,
200 const wxMBConv& conv = wxConvAuto());
201
202 /**
203 Destroys the wxDataInputStream object.
204 */
205 ~wxDataInputStream();
206
207 /**
208 If @a be_order is @true, all data will be read in big-endian order,
209 such as written by programs on a big endian architecture (e.g. Sparc)
210 or written by Java-Streams (which always use big-endian order).
211 */
212 void BigEndianOrdered(bool be_order);
213
214 /**
215 Reads a single byte from the stream.
216 */
217 wxUint8 Read8();
218 /**
219 Reads bytes from the stream in a specified buffer. The amount of bytes
220 to read is specified by the @a size variable.
221 */
222 void Read8(wxUint8* buffer, size_t size);
223
224 /**
225 Reads a 16 bit unsigned integer from the stream.
226 */
227 wxUint16 Read16();
228 /**
229 Reads 16 bit unsigned integers from the stream in a specified buffer.
230 The amount of 16 bit unsigned integers to read is specified by the
231 @a size variable.
232 */
233 void Read16(wxUint16* buffer, size_t size);
234
235 /**
236 Reads a 32 bit unsigned integer from the stream.
237 */
238 wxUint32 Read32();
239 /**
240 Reads 32 bit unsigned integers from the stream in a specified buffer.
241 The amount of 32 bit unsigned integers to read is specified by the
242 @a size variable.
243 */
244 void Read32(wxUint32* buffer, size_t size);
245
246 /**
247 Reads a 64 bit unsigned integer from the stream.
248 */
249 wxUint64 Read64();
250 /**
251 Reads 64 bit unsigned integers from the stream in a specified buffer.
252 The amount of 64 bit unsigned integers to read is specified by the
253 @a size variable.
254 */
255 void Read64(wxUint64* buffer, size_t size);
256
257 /**
258 Reads a double (IEEE encoded) from the stream.
259 */
260 double ReadDouble();
261 /**
262 Reads double data (IEEE encoded) from the stream in a specified buffer.
263 The amount of doubles to read is specified by the @a size variable.
264 */
265 void ReadDouble(double* buffer, size_t size);
266
267 /**
268 Reads a string from a stream. Actually, this function first reads a
269 long integer specifying the length of the string (without the last null
270 character) and then reads the string.
271
272 In Unicode build of wxWidgets, the fuction first reads multibyte
273 (char*) string from the stream and then converts it to Unicode using
274 the @e conv object passed to constructor and returns the result as
275 wxString. You are responsible for using the same convertor as when
276 writing the stream.
277
278 @see wxDataOutputStream::WriteString()
279 */
280 wxString ReadString();
281 };
282