1 % ----------------------------------------------------------------------------
3 % ----------------------------------------------------------------------------
4 \section{\class{wxDataInputStream
}}\label{wxdatainputstream
}
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.
10 If you want to read data from text files (or streams) use
11 \helpref{wxTextInputStream
}{wxtextinputstream
} instead.
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.
22 wxFileInputStream input( "mytext.dat" );
23 wxDataInputStream store( input );
28 store >> i1; // read a
8 bit integer.
29 store >> i1 >> f2; // read a
8 bit integer followed by float.
30 store >> line; // read a text line
33 See also
\helpref{wxDataOutputStream
}{wxdataoutputstream
}.
35 \wxheading{Derived from
}
39 \wxheading{Include files
}
43 \latexignore{\rtfignore{\wxheading{Members
}}}
45 \membersection{wxDataInputStream::wxDataInputStream
}\label{wxdatainputstreamconstr
}
47 \func{}{wxDataInputStream
}{\param{wxInputStream\&
}{ stream
}}
49 Constructs a datastream object from an input stream. Only read methods will
52 \wxheading{Parameters
}
54 \docparam{stream
}{The input stream.
}
56 \membersection{wxDataInputStream::
\destruct{wxDataInputStream
}}
58 \func{}{\destruct{wxDataInputStream
}}{\void}
60 Destroys the wxDataInputStream object.
62 \membersection{wxDataInputStream::BigEndianOrdered
}
64 \func{void
}{BigEndianOrdered
}{\param{bool
}{ be
\_order}}
66 If
{\it be
\_order} is TRUE, all data will be read in big-endian
67 order, such as written by programs on a big endian architecture
68 (e.g. Sparc) or written by Java-Streams (which always use
71 \membersection{wxDataInputStream::Read8
}
73 \func{wxUint8
}{Read8
}{\void}
75 Reads a single byte from the stream.
77 \membersection{wxDataInputStream::Read16
}
79 \func{wxUint16
}{Read16
}{\void}
81 Reads a
16 bit integer from the stream.
83 \membersection{wxDataInputStream::Read32
}
85 \func{wxUint32
}{Read32
}{\void}
87 Reads a
32 bit integer from the stream.
89 \membersection{wxDataInputStream::ReadDouble
}
91 \func{double
}{ReadDouble
}{\void}
93 Reads a double (IEEE encoded) from the stream.
95 \membersection{wxDataInputStream::ReadString
}
97 \func{wxString
}{ReadString
}{\void}
99 Reads a string from a stream. Actually, this function first reads a long integer
100 specifying the length of the string (without the last null character) and then
103 % ----------------------------------------------------------------------------
105 % ----------------------------------------------------------------------------
107 \section{\class{wxDataOutputStream
}}\label{wxdataoutputstream
}
109 This class provides functions that write binary data types in a
110 portable way. Data can be written in either big-endian or litte-endian
111 format, little-endian being the default on all architectures.
113 If you want to write data to text files (or streams) use
114 \helpref{wxTextOutputStream
}{wxtextoutputstream
} instead.
116 The << operator is overloaded and you can use this class like a standard
117 C++ iostream. See
\helpref{wxDataInputStream
}{wxdatainputstream
} for its
120 See also
\helpref{wxDataInputStream
}{wxdatainputstream
}.
122 \wxheading{Derived from
}
126 \latexignore{\rtfignore{\wxheading{Members
}}}
128 \membersection{wxDataOutputStream::wxDataOutputStream
}\label{wxdataoutputstreamconstr
}
130 \func{}{wxDataOutputStream
}{\param{wxOutputStream\&
}{ stream
}}
132 Constructs a datastream object from an output stream. Only write methods will
135 \wxheading{Parameters
}
137 \docparam{stream
}{The output stream.
}
139 \membersection{wxDataOutputStream::
\destruct{wxDataOutputStream
}}
141 \func{}{\destruct{wxDataOutputStream
}}{\void}
143 Destroys the wxDataOutputStream object.
145 \membersection{wxDataOutputStream::BigEndianOrdered
}
147 \func{void
}{BigEndianOrdered
}{\param{bool
}{ be
\_order}}
149 If
{\it be
\_order} is TRUE, all data will be written in big-endian
150 order, e.g. for reading on a Sparc or from Java-Streams (which
151 always use big-endian order), otherwise data will be written in
154 \membersection{wxDataOutputStream::Write8
}
156 \func{void
}{Write8
}{{\param wxUint8
}{i8
}}
158 Writes the single byte
{\it i8
} to the stream.
160 \membersection{wxDataOutputStream::Write16
}
162 \func{void
}{Write16
}{{\param wxUint16
}{i16
}}
164 Writes the
16 bit integer
{\it i16
} to the stream.
166 \membersection{wxDataOutputStream::Write32
}
168 \func{void
}{Write32
}{{\param wxUint32
}{i32
}}
170 Writes the
32 bit integer
{\it i32
} to the stream.
172 \membersection{wxDataOutputStream::WriteDouble
}
174 \func{void
}{WriteDouble
}{{\param double
}{f
}}
176 Writes the double
{\it f
} to the stream using the IEEE format.
178 \membersection{wxDataOutputStream::WriteString
}
180 \func{void
}{WriteString
}{{\param const wxString\&
}{string
}}
182 Writes
{\it string
} to the stream. Actually, this method writes the size of
183 the string before writing
{\it string
} itself.