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