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