]>
Commit | Line | Data |
---|---|---|
c7d9131a GL |
1 | % ---------------------------------------------------------------------------- |
2 | % wxDataInputStream | |
3 | % ---------------------------------------------------------------------------- | |
631f1bfe | 4 | \section{\class{wxDataInputStream}}\label{wxdatainputstream} |
4d1f281b | 5 | |
7ff14117 RR |
6 | This class provides functions that read binary data types in a |
7 | portable way. Data can be read in either big-endian or litte-endian | |
8 | format, little-endian being the default on all architectures. | |
9 | ||
10 | If you want to read data from text files (or streams) use | |
11 | \helpref{wxTextInputStream}{wxtextinputstream} instead. | |
12 | ||
13 | The >> operator is overloaded and you can use this class like a standard C++ iostream. | |
14 | Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc | |
15 | and on a typical 32-bit computer, none of these match to the "long" type (wxInt32 | |
16 | is defined as signed int on 32-bit architectures) so that you cannot use long. To avoid | |
17 | problems (here and elsewhere), make use of the wxInt32, wxUint32, etc types. | |
18 | ||
19 | For example: | |
20 | \begin{verbatim} | |
21 | wxFileInputStream input( "mytext.dat" ); | |
22 | wxDataInputStream store( input ); | |
23 | wxUint8 i1; | |
24 | float f2; | |
25 | wxString line; | |
26 | ||
27 | store >> i1; // read a 8 bit integer. | |
28 | store >> i1 >> f2; // read a 8 bit integer followed by float. | |
29 | store >> line; // read a text line | |
30 | \end{verbatim} | |
31 | ||
32 | See also \helpref{wxDataOutputStream}{wxdataoutputstream}. | |
4d1f281b | 33 | |
954b8ae6 JS |
34 | \wxheading{Include files} |
35 | ||
36 | <wx/datstrm.h> | |
37 | ||
631f1bfe | 38 | \latexignore{\rtfignore{\wxheading{Members}}} |
4d1f281b | 39 | |
631f1bfe | 40 | \membersection{wxDataInputStream::wxDataInputStream}\label{wxdatainputstreamconstr} |
4d1f281b | 41 | |
631f1bfe | 42 | \func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}} |
4d1f281b | 43 | |
631f1bfe | 44 | Constructs a datastream object from an input stream. Only read methods will |
4d1f281b GL |
45 | be available. |
46 | ||
47 | \wxheading{Parameters} | |
48 | ||
631f1bfe | 49 | \docparam{stream}{The input stream.} |
4d1f281b | 50 | |
631f1bfe | 51 | \membersection{wxDataInputStream::\destruct{wxDataInputStream}} |
4d1f281b | 52 | |
631f1bfe | 53 | \func{}{\destruct{wxDataInputStream}}{\void} |
4d1f281b | 54 | |
631f1bfe | 55 | Destroys the wxDataInputStream object. |
4d1f281b | 56 | |
d7cb14ce | 57 | \membersection{wxDataInputStream::BigEndianOrdered} |
7ff14117 | 58 | |
d7cb14ce | 59 | \func{void}{BigEndianOrdered}{\param{bool}{ be_order}} |
7ff14117 RR |
60 | |
61 | If {\it be_order} is TRUE, all data will be read in big-endian | |
62 | order, such as written by programs on a big endian architecture | |
63 | (e.g. Sparc) or written by Java-Streams (which always use | |
64 | big-endian order). | |
65 | ||
631f1bfe | 66 | \membersection{wxDataInputStream::Read8} |
4d1f281b | 67 | |
7ff14117 | 68 | \func{wxUint8}{Read8}{\void} |
4d1f281b GL |
69 | |
70 | Reads a single byte from the stream. | |
71 | ||
631f1bfe | 72 | \membersection{wxDataInputStream::Read16} |
4d1f281b | 73 | |
7ff14117 | 74 | \func{wxUint16}{Read16}{\void} |
4d1f281b GL |
75 | |
76 | Reads a 16 bit integer from the stream. | |
77 | ||
631f1bfe | 78 | \membersection{wxDataInputStream::Read32} |
4d1f281b | 79 | |
7ff14117 | 80 | \func{wxUint32}{Read32}{\void} |
4d1f281b GL |
81 | |
82 | Reads a 32 bit integer from the stream. | |
83 | ||
631f1bfe | 84 | \membersection{wxDataInputStream::ReadDouble} |
4d1f281b GL |
85 | |
86 | \func{double}{ReadDouble}{\void} | |
87 | ||
88 | Reads a double (IEEE encoded) from the stream. | |
89 | ||
631f1bfe | 90 | \membersection{wxDataInputStream::ReadString} |
4d1f281b | 91 | |
631f1bfe | 92 | \func{wxString}{wxDataInputStream::ReadString}{\void} |
4d1f281b | 93 | |
631f1bfe | 94 | Reads a string from a stream. Actually, this function first reads a long integer |
4d1f281b GL |
95 | specifying the length of the string (without the last null character) and then |
96 | reads the string. | |
97 | ||
c7d9131a GL |
98 | % ---------------------------------------------------------------------------- |
99 | % wxDataOutputStream | |
100 | % ---------------------------------------------------------------------------- | |
101 | ||
631f1bfe JS |
102 | \section{\class{wxDataOutputStream}}\label{wxdataoutputstream} |
103 | ||
7ff14117 RR |
104 | This class provides functions that write binary data types in a |
105 | portable way. Data can be written in either big-endian or litte-endian | |
106 | format, little-endian being the default on all architectures. | |
107 | ||
108 | If you want to write data to text files (or streams) use | |
109 | \helpref{wxTextOutputStream}{wxtextoutputstream} instead. | |
110 | ||
111 | The << operator is overloaded and you can use this class like a standard | |
112 | C++ iostream. See \helpref{wxDataInputStream}{wxdatainputstream} for its | |
113 | usage and caveats. | |
114 | ||
115 | See also \helpref{wxDataInputStream}{wxdatainputstream}. | |
631f1bfe JS |
116 | |
117 | \latexignore{\rtfignore{\wxheading{Members}}} | |
118 | ||
119 | \membersection{wxDataOutputStream::wxDataOutputStream}\label{wxdataoutputstreamconstr} | |
120 | ||
d7cb14ce | 121 | \func{}{wxDataOutputStream}{\param{wxOutputStream\&}{ stream}} |
631f1bfe | 122 | |
7ff14117 | 123 | Constructs a datastream object from an output stream. Only write methods will |
631f1bfe JS |
124 | be available. |
125 | ||
126 | \wxheading{Parameters} | |
127 | ||
128 | \docparam{stream}{The output stream.} | |
129 | ||
130 | \membersection{wxDataOutputStream::\destruct{wxDataOutputStream}} | |
131 | ||
132 | \func{}{\destruct{wxDataOutputStream}}{\void} | |
133 | ||
134 | Destroys the wxDataOutputStream object. | |
135 | ||
d7cb14ce | 136 | \membersection{wxDataOutputStream::BigEndianOrdered} |
7ff14117 | 137 | |
d7cb14ce | 138 | \func{void}{BigEndianOrdered}{\param{bool}{ be_order}} |
7ff14117 RR |
139 | |
140 | If {\it be_order} is TRUE, all data will be written in big-endian | |
141 | order, e.g. for reading on a Sparc or from Java-Streams (which | |
142 | always use big-endian order), otherwise data will be written in | |
143 | little-endian order. | |
144 | ||
631f1bfe | 145 | \membersection{wxDataOutputStream::Write8} |
4d1f281b | 146 | |
7ff14117 | 147 | \func{void}{wxDataOutputStream::Write8}{{\param wxUint8 }{i8}} |
4d1f281b GL |
148 | |
149 | Writes the single byte {\it i8} to the stream. | |
150 | ||
631f1bfe | 151 | \membersection{wxDataOutputStream::Write16} |
4d1f281b | 152 | |
7ff14117 | 153 | \func{void}{wxDataOutputStream::Write16}{{\param wxUint16 }{i16}} |
4d1f281b GL |
154 | |
155 | Writes the 16 bit integer {\it i16} to the stream. | |
156 | ||
631f1bfe | 157 | \membersection{wxDataOutputStream::Write32} |
4d1f281b | 158 | |
7ff14117 | 159 | \func{void}{wxDataOutputStream::Write32}{{\param wxUint32 }{i32}} |
4d1f281b GL |
160 | |
161 | Writes the 32 bit integer {\it i32} to the stream. | |
162 | ||
631f1bfe | 163 | \membersection{wxDataOutputStream::WriteDouble} |
4d1f281b | 164 | |
631f1bfe | 165 | \func{void}{wxDataOutputStream::WriteDouble}{{\param double }{f}} |
4d1f281b GL |
166 | |
167 | Writes the double {\it f} to the stream using the IEEE format. | |
168 | ||
40b480c3 JS |
169 | \membersection{wxDataOutputStream::WriteString} |
170 | ||
171 | \func{void}{wxDataOutputStream::WriteString}{{\param const wxString\& }{string}} | |
172 | ||
173 | Writes {\it string} to the stream. Actually, this method writes the size of | |
174 | the string before writing {\it string} itself. | |
22d6efa8 | 175 |