]>
git.saurik.com Git - wxWidgets.git/blob - interface/datstrm.h
3f6a8ead3736effab967f3f068df15fd90367ccb
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxDataOutputStream class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDataOutputStream
13 This class provides functions that write binary data types in a
14 portable way. Data can be written in either big-endian or little-endian
15 format, little-endian being the default on all architectures.
17 If you want to write data to text files (or streams) use
18 wxTextOutputStream instead.
20 The operator is overloaded and you can use this class like a standard
21 C++ iostream. See wxDataInputStream for its
24 See also wxDataInputStream.
29 class wxDataOutputStream
35 Constructs a datastream object from an output stream. Only write methods will
36 be available. The second form is only available in Unicode build of wxWidgets.
41 Charset conversion object object used to encoding Unicode
42 strings before writing them to the stream
43 in Unicode mode (see WriteString()
44 documentation for detailed description). Note that you must not destroy
45 conv before you destroy this wxDataOutputStream instance! It is
46 recommended to use default value (UTF-8).
48 wxDataOutputStream(wxOutputStream
& stream
);
49 wxDataOutputStream(wxOutputStream
& stream
);
53 Destroys the wxDataOutputStream object.
55 ~wxDataOutputStream();
58 If @a be_order is @true, all data will be written in big-endian
59 order, e.g. for reading on a Sparc or from Java-Streams (which
60 always use big-endian order), otherwise data will be written in
63 void BigEndianOrdered(bool be_order
);
67 Writes an array of 16 bit unsigned integer to the stream. The amount of
68 16 bit unsigned integer to write is specified with the @a size variable.
70 void Write16(wxUint16 i16
);
71 void Write16(const wxUint16
* buffer
, size_t size
);
76 Writes an array of 32 bit unsigned integer to the stream. The amount of
77 32 bit unsigned integer to write is specified with the @a size variable.
79 void Write32(wxUint32 i32
);
80 void Write32(const wxUint32
* buffer
, size_t size
);
85 Writes an array of 64 bit unsigned integer to the stream. The amount of
86 64 bit unsigned integer to write is specified with the @a size variable.
88 void Write64(wxUint64 i64
);
89 void Write64(const wxUint64
* buffer
, size_t size
);
94 Writes an array of bytes to the stream. The amount of bytes to write is
95 specified with the @a size variable.
97 void Write8(wxUint8 i8
);
98 void Write8(const wxUint8
* buffer
, size_t size
);
103 Writes an array of double to the stream. The amount of double to write is
104 specified with the @a size variable.
106 void WriteDouble(double f
);
107 void WriteDouble(const double* buffer
, size_t size
);
111 Writes @a string to the stream. Actually, this method writes the size of
112 the string before writing @a string itself.
113 In ANSI build of wxWidgets, the string is written to the stream in exactly
114 same way it is represented in memory. In Unicode build, however, the string
115 is first converted to multibyte representation with @e conv object passed
116 to stream's constructor (consequently, ANSI application can read data
117 written by Unicode application, as long as they agree on encoding) and this
118 representation is written to the stream. UTF-8 is used by default.
120 void WriteString(const wxString
& string
);
125 @class wxDataInputStream
128 This class provides functions that read binary data types in a
129 portable way. Data can be read in either big-endian or little-endian
130 format, little-endian being the default on all architectures.
132 If you want to read data from text files (or streams) use
133 wxTextInputStream instead.
135 The operator is overloaded and you can use this class like a standard C++
137 Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc
138 and on a typical 32-bit computer, none of these match to the "long" type
140 is defined as signed int on 32-bit architectures) so that you cannot use long.
142 problems (here and elsewhere), make use of the wxInt32, wxUint32, etc types.
147 wxFileInputStream input( "mytext.dat" );
148 wxDataInputStream store( input );
153 store i1; // read a 8 bit integer.
154 store i1 f2; // read a 8 bit integer followed by float.
155 store line; // read a text line
158 See also wxDataOutputStream.
163 class wxDataInputStream
169 Constructs a datastream object from an input stream. Only read methods will
170 be available. The second form is only available in Unicode build of wxWidgets.
175 Charset conversion object object used to decode strings in Unicode
176 mode (see ReadString()
177 documentation for detailed description). Note that you must not destroy
178 conv before you destroy this wxDataInputStream instance!
180 wxDataInputStream(wxInputStream
& stream
);
181 wxDataInputStream(wxInputStream
& stream
);
185 Destroys the wxDataInputStream object.
187 ~wxDataInputStream();
190 If @a be_order is @true, all data will be read in big-endian
191 order, such as written by programs on a big endian architecture
192 (e.g. Sparc) or written by Java-Streams (which always use
195 void BigEndianOrdered(bool be_order
);
199 Reads 16 bit unsigned integers from the stream in a specified buffer. the
200 amount of 16 bit unsigned integer to read is specified by the @a size variable.
203 void Read16(wxUint16
* buffer
, size_t size
);
208 Reads 32 bit unsigned integers from the stream in a specified buffer. the
210 32 bit unsigned integer to read is specified by the @a size variable.
213 void Read32(wxUint32
* buffer
, size_t size
);
218 Reads 64 bit unsigned integers from the stream in a specified buffer. the
220 64 bit unsigned integer to read is specified by the @a size variable.
223 void Read64(wxUint64
* buffer
, size_t size
);
228 Reads bytes from the stream in a specified buffer. The amount of
229 bytes to read is specified by the @a size variable.
232 void Read8(wxUint8
* buffer
, size_t size
);
237 Reads double data (IEEE encoded) from the stream in a specified buffer. the
239 double to read is specified by the @a size variable.
242 void ReadDouble(double* buffer
, size_t size
);
246 Reads a string from a stream. Actually, this function first reads a long
247 integer specifying the length of the string (without the last null character)
248 and then reads the string.
249 In Unicode build of wxWidgets, the fuction first reads multibyte (char*)
250 string from the stream and then converts it to Unicode using the @e conv
251 object passed to constructor and returns the result as wxString. You are
252 responsible for using the same convertor as when writing the stream.
253 See also wxDataOutputStream::WriteString.
255 wxString
ReadString();