1 \section{\class{wxDataInputStream
}}\label{wxdatainputstream
}
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.
7 If you want to read data from text files (or streams) use
8 \helpref{wxTextInputStream
}{wxtextinputstream
} instead.
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.
19 wxFileInputStream input( "mytext.dat" );
20 wxDataInputStream store( input );
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
30 See also
\helpref{wxDataOutputStream
}{wxdataoutputstream
}.
32 \wxheading{Derived from
}
36 \wxheading{Include files
}
40 \latexignore{\rtfignore{\wxheading{Members
}}}
42 \membersection{wxDataInputStream::wxDataInputStream
}\label{wxdatainputstreamctor
}
44 \func{}{wxDataInputStream
}{\param{wxInputStream\&
}{ stream
}}
46 \func{}{wxDataInputStream
}{\param{wxInputStream\&
}{ stream
},
\param{wxMBConv\&
}{ conv = wxMBConvUTF8
}}
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 wxWidgets.
51 \wxheading{Parameters
}
53 \docparam{stream
}{The input stream.
}
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!
}
60 \membersection{wxDataInputStream::
\destruct{wxDataInputStream
}}\label{wxdatainputstreamdtor
}
62 \func{}{\destruct{wxDataInputStream
}}{\void}
64 Destroys the wxDataInputStream object.
66 \membersection{wxDataInputStream::BigEndianOrdered
}\label{wxdatainputstreambigendianordered
}
68 \func{void
}{BigEndianOrdered
}{\param{bool
}{ be
\_order}}
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
75 \membersection{wxDataInputStream::Read8
}\label{wxdatainputstreamread8
}
77 \func{wxUint8
}{Read8
}{\void}
79 Reads a single byte from the stream.
81 \func{void
}{Read8
}{\param{wxUint8 *
}{buffer
},
\param{size
\_t }{size
}}
83 Reads bytes from the stream in a specified buffer. The amount of
84 bytes to read is specified by the
{\it size
} variable.
86 \membersection{wxDataInputStream::Read16
}\label{wxdatainputstreamread16
}
88 \func{wxUint16
}{Read16
}{\void}
90 Reads a
16 bit unsigned integer from the stream.
92 \func{void
}{Read16
}{\param{wxUint16 *
}{buffer
},
\param{size
\_t }{size
}}
94 Reads
16 bit unsigned integers from the stream in a specified buffer. the
95 amount of
16 bit unsigned integer to read is specified by the
{\it size
} variable.
97 \membersection{wxDataInputStream::Read32
}\label{wxdatainputstreamread32
}
99 \func{wxUint32
}{Read32
}{\void}
101 Reads a
32 bit unsigned integer from the stream.
103 \func{void
}{Read32
}{\param{wxUint32 *
}{buffer
},
\param{size
\_t }{size
}}
105 Reads
32 bit unsigned integers from the stream in a specified buffer. the amount of
106 32 bit unsigned integer to read is specified by the
{\it size
} variable.
108 \membersection{wxDataInputStream::Read64
}\label{wxdatainputstreamread64
}
110 \func{wxUint64
}{Read64
}{\void}
112 Reads a
64 bit unsigned integer from the stream.
114 \func{void
}{Read64
}{\param{wxUint64 *
}{buffer
},
\param{size
\_t }{size
}}
116 Reads
64 bit unsigned integers from the stream in a specified buffer. the amount of
117 64 bit unsigned integer to read is specified by the
{\it size
} variable.
119 \membersection{wxDataInputStream::ReadDouble
}\label{wxdatainputstreamreaddouble
}
121 \func{double
}{ReadDouble
}{\void}
123 Reads a double (IEEE encoded) from the stream.
125 \func{void
}{ReadDouble
}{\param{double *
}{buffer
},
\param{size
\_t }{size
}}
127 Reads double data (IEEE encoded) from the stream in a specified buffer. the amount of
128 double to read is specified by the
{\it size
} variable.
130 \membersection{wxDataInputStream::ReadString
}\label{wxdatainputstreamreadstring
}
132 \func{wxString
}{ReadString
}{\void}
134 Reads a string from a stream. Actually, this function first reads a long
135 integer specifying the length of the string (without the last null character)
136 and then reads the string.
138 In Unicode build of wxWidgets, the fuction first reads multibyte (char*)
139 string from the stream and then converts it to Unicode using the
{\it conv
}
140 object passed to constructor and returns the result as wxString. You are
141 responsible for using the same convertor as when writing the stream.
143 See also
\helpref{wxDataOutputStream::WriteString
}{wxdataoutputstreamwritestring
}.