]>
Commit | Line | Data |
---|---|---|
f6106dae VZ |
1 | \section{\class{wxDataInputStream}}\label{wxdatainputstream} |
2 | ||
3 | This class provides functions that read binary data types in a | |
2edb0bde | 4 | portable way. Data can be read in either big-endian or little-endian |
f6106dae VZ |
5 | format, little-endian being the default on all architectures. |
6 | ||
7 | If you want to read data from text files (or streams) use | |
8 | \helpref{wxTextInputStream}{wxtextinputstream} instead. | |
9 | ||
10 | The >> operator is overloaded and you can use this class like a standard C++ iostream. | |
11 | Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc | |
12 | and on a typical 32-bit computer, none of these match to the "long" type (wxInt32 | |
13 | is defined as signed int on 32-bit architectures) so that you cannot use long. To avoid | |
14 | problems (here and elsewhere), make use of the wxInt32, wxUint32, etc types. | |
15 | ||
16 | For example: | |
17 | ||
18 | \begin{verbatim} | |
19 | wxFileInputStream input( "mytext.dat" ); | |
20 | wxDataInputStream store( input ); | |
21 | wxUint8 i1; | |
22 | float f2; | |
23 | wxString line; | |
24 | ||
25 | store >> i1; // read a 8 bit integer. | |
26 | store >> i1 >> f2; // read a 8 bit integer followed by float. | |
27 | store >> line; // read a text line | |
28 | \end{verbatim} | |
29 | ||
30 | See also \helpref{wxDataOutputStream}{wxdataoutputstream}. | |
31 | ||
32 | \wxheading{Derived from} | |
33 | ||
34 | None | |
35 | ||
36 | \wxheading{Include files} | |
37 | ||
38 | <wx/datstrm.h> | |
39 | ||
a7af285d VZ |
40 | \wxheading{Library} |
41 | ||
42 | \helpref{wxBase}{librarieslist} | |
43 | ||
f6106dae VZ |
44 | \latexignore{\rtfignore{\wxheading{Members}}} |
45 | ||
b236c10f | 46 | \membersection{wxDataInputStream::wxDataInputStream}\label{wxdatainputstreamctor} |
f6106dae VZ |
47 | |
48 | \func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}} | |
49 | ||
5487ff0f | 50 | \func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}, \param{const wxMBConv\&}{ conv = wxConvAuto()}} |
a99acbb0 | 51 | |
f6106dae | 52 | Constructs a datastream object from an input stream. Only read methods will |
fc2171bd | 53 | be available. The second form is only available in Unicode build of wxWidgets. |
f6106dae VZ |
54 | |
55 | \wxheading{Parameters} | |
56 | ||
57 | \docparam{stream}{The input stream.} | |
58 | ||
a99acbb0 VS |
59 | \docparam{conv}{Charset conversion object object used to decode strings in Unicode |
60 | mode (see \helpref{wxDataInputStream::ReadString}{wxdatainputstreamreadstring} | |
61 | documentation for detailed description). Note that you must not destroy | |
62 | {\it conv} before you destroy this wxDataInputStream instance!} | |
63 | ||
b236c10f | 64 | \membersection{wxDataInputStream::\destruct{wxDataInputStream}}\label{wxdatainputstreamdtor} |
f6106dae VZ |
65 | |
66 | \func{}{\destruct{wxDataInputStream}}{\void} | |
67 | ||
68 | Destroys the wxDataInputStream object. | |
69 | ||
b236c10f | 70 | \membersection{wxDataInputStream::BigEndianOrdered}\label{wxdatainputstreambigendianordered} |
f6106dae VZ |
71 | |
72 | \func{void}{BigEndianOrdered}{\param{bool}{ be\_order}} | |
73 | ||
cc81d32f | 74 | If {\it be\_order} is true, all data will be read in big-endian |
f6106dae VZ |
75 | order, such as written by programs on a big endian architecture |
76 | (e.g. Sparc) or written by Java-Streams (which always use | |
77 | big-endian order). | |
78 | ||
b236c10f | 79 | \membersection{wxDataInputStream::Read8}\label{wxdatainputstreamread8} |
f6106dae VZ |
80 | |
81 | \func{wxUint8}{Read8}{\void} | |
82 | ||
83 | Reads a single byte from the stream. | |
84 | ||
53663be8 VZ |
85 | \func{void}{Read8}{\param{wxUint8 *}{buffer}, \param{size\_t }{size}} |
86 | ||
87 | Reads bytes from the stream in a specified buffer. The amount of | |
88 | bytes to read is specified by the {\it size} variable. | |
89 | ||
b236c10f | 90 | \membersection{wxDataInputStream::Read16}\label{wxdatainputstreamread16} |
f6106dae VZ |
91 | |
92 | \func{wxUint16}{Read16}{\void} | |
93 | ||
4d1cbdbe | 94 | Reads a 16 bit unsigned integer from the stream. |
f6106dae | 95 | |
53663be8 VZ |
96 | \func{void}{Read16}{\param{wxUint16 *}{buffer}, \param{size\_t }{size}} |
97 | ||
98 | Reads 16 bit unsigned integers from the stream in a specified buffer. the | |
99 | amount of 16 bit unsigned integer to read is specified by the {\it size} variable. | |
100 | ||
b236c10f | 101 | \membersection{wxDataInputStream::Read32}\label{wxdatainputstreamread32} |
f6106dae VZ |
102 | |
103 | \func{wxUint32}{Read32}{\void} | |
104 | ||
4d1cbdbe VZ |
105 | Reads a 32 bit unsigned integer from the stream. |
106 | ||
53663be8 VZ |
107 | \func{void}{Read32}{\param{wxUint32 *}{buffer}, \param{size\_t }{size}} |
108 | ||
109 | Reads 32 bit unsigned integers from the stream in a specified buffer. the amount of | |
110 | 32 bit unsigned integer to read is specified by the {\it size} variable. | |
111 | ||
bee44427 | 112 | \membersection{wxDataInputStream::Read64}\label{wxdatainputstreamread64} |
4d1cbdbe VZ |
113 | |
114 | \func{wxUint64}{Read64}{\void} | |
115 | ||
116 | Reads a 64 bit unsigned integer from the stream. | |
f6106dae | 117 | |
53663be8 VZ |
118 | \func{void}{Read64}{\param{wxUint64 *}{buffer}, \param{size\_t }{size}} |
119 | ||
120 | Reads 64 bit unsigned integers from the stream in a specified buffer. the amount of | |
121 | 64 bit unsigned integer to read is specified by the {\it size} variable. | |
122 | ||
b236c10f | 123 | \membersection{wxDataInputStream::ReadDouble}\label{wxdatainputstreamreaddouble} |
f6106dae VZ |
124 | |
125 | \func{double}{ReadDouble}{\void} | |
126 | ||
127 | Reads a double (IEEE encoded) from the stream. | |
128 | ||
53663be8 VZ |
129 | \func{void}{ReadDouble}{\param{double *}{buffer}, \param{size\_t }{size}} |
130 | ||
131 | Reads double data (IEEE encoded) from the stream in a specified buffer. the amount of | |
132 | double to read is specified by the {\it size} variable. | |
133 | ||
a99acbb0 | 134 | \membersection{wxDataInputStream::ReadString}\label{wxdatainputstreamreadstring} |
f6106dae VZ |
135 | |
136 | \func{wxString}{ReadString}{\void} | |
137 | ||
a99acbb0 VS |
138 | Reads a string from a stream. Actually, this function first reads a long |
139 | integer specifying the length of the string (without the last null character) | |
140 | and then reads the string. | |
f6106dae | 141 | |
fc2171bd | 142 | In Unicode build of wxWidgets, the fuction first reads multibyte (char*) |
a99acbb0 VS |
143 | string from the stream and then converts it to Unicode using the {\it conv} |
144 | object passed to constructor and returns the result as wxString. You are | |
145 | responsible for using the same convertor as when writing the stream. | |
f6106dae | 146 | |
a99acbb0 | 147 | See also \helpref{wxDataOutputStream::WriteString}{wxdataoutputstreamwritestring}. |
0497e172 | 148 |