]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/datistrm.tex
Unicodification of wxDataStreams
[wxWidgets.git] / docs / latex / wx / datistrm.tex
1 \section{\class{wxDataInputStream}}\label{wxdatainputstream}
2
3 This class provides functions that read binary data types in a
4 portable way. Data can be read in either big-endian or little-endian
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
40 \latexignore{\rtfignore{\wxheading{Members}}}
41
42 \membersection{wxDataInputStream::wxDataInputStream}\label{wxdatainputstreamconstr}
43
44 \func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}}
45
46 \func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}, \param{wxMBConv\&}{ conv = wxMBConvUTF8}}
47
48 Constructs a datastream object from an input stream. Only read methods will
49 be available. The second form is only available in Unicode build of wxWindows.
50
51 \wxheading{Parameters}
52
53 \docparam{stream}{The input stream.}
54
55 \docparam{conv}{Charset conversion object object used to decode strings in Unicode
56 mode (see \helpref{wxDataInputStream::ReadString}{wxdatainputstreamreadstring}
57 documentation for detailed description). Note that you must not destroy
58 {\it conv} before you destroy this wxDataInputStream instance!}
59
60 \membersection{wxDataInputStream::\destruct{wxDataInputStream}}
61
62 \func{}{\destruct{wxDataInputStream}}{\void}
63
64 Destroys the wxDataInputStream object.
65
66 \membersection{wxDataInputStream::BigEndianOrdered}
67
68 \func{void}{BigEndianOrdered}{\param{bool}{ be\_order}}
69
70 If {\it be\_order} is TRUE, all data will be read in big-endian
71 order, such as written by programs on a big endian architecture
72 (e.g. Sparc) or written by Java-Streams (which always use
73 big-endian order).
74
75 \membersection{wxDataInputStream::Read8}
76
77 \func{wxUint8}{Read8}{\void}
78
79 Reads a single byte from the stream.
80
81 \membersection{wxDataInputStream::Read16}
82
83 \func{wxUint16}{Read16}{\void}
84
85 Reads a 16 bit integer from the stream.
86
87 \membersection{wxDataInputStream::Read32}
88
89 \func{wxUint32}{Read32}{\void}
90
91 Reads a 32 bit integer from the stream.
92
93 \membersection{wxDataInputStream::ReadDouble}
94
95 \func{double}{ReadDouble}{\void}
96
97 Reads a double (IEEE encoded) from the stream.
98
99 \membersection{wxDataInputStream::ReadString}\label{wxdatainputstreamreadstring}
100
101 \func{wxString}{ReadString}{\void}
102
103 Reads a string from a stream. Actually, this function first reads a long
104 integer specifying the length of the string (without the last null character)
105 and then reads the string.
106
107 In Unicode build of wxWindows, the fuction first reads multibyte (char*)
108 string from the stream and then converts it to Unicode using the {\it conv}
109 object passed to constructor and returns the result as wxString. You are
110 responsible for using the same convertor as when writing the stream.
111
112 See also \helpref{wxDataOutputStream::WriteString}{wxdataoutputstreamwritestring}.