This class provides functions that read text datas using an input stream. So, you can read text floats, integers.
The wxTextInputStream correctly reads text files (or streams) in DOS, Macintosh and Unix formats and reports a single newline char as a line ending.
Operator >> is overloaded and you can use this class like a standard C++ iostream. Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc and on a typical 32-bit computer, none of these match to the "long" type (wxInt32 is defined as int on 32-bit architectures) so that you cannot use long. To avoid problems (here and elsewhere), make use of wxInt32, wxUint32 and similar types.
For example:
wxFileInputStream input( "mytext.txt" ); wxTextInputStream text( input ); wxUint8 i1; float f2; wxString line; text >> i1; // read a 8 bit integer. text >> i1 >> f2; // read a 8 bit integer followed by float. text >> line; // read a text lineInclude files
<wx/txtstrm.h>
Members
wxTextInputStream::wxTextInputStream
wxTextInputStream::~wxTextInputStream
wxTextInputStream::Read8
wxTextInputStream::Read16
wxTextInputStream::Read32
wxTextInputStream::ReadDouble
wxTextInputStream::ReadLine
wxTextInputStream::ReadString
wxTextInputStream::ReadWord
wxTextInputStream::SetStringSeparators
wxTextInputStream(wxInputStream& stream)
wxTextInputStream(wxInputStream& stream, wxMBConv& conv = wxMBConvUTF8)
Constructs a text stream object from an input stream. Only read methods will be available. The second form is available only in Unicode mode and lets you set the encoding of the text.
Parameters
stream
~wxTextInputStream()
Destroys the wxTextInputStream object.
wxUint8 Read8()
Reads a single byte from the stream.
wxUint16 Read16()
Reads a 16 bit integer from the stream.
wxUint32 Read32()
Reads a 32 bit integer from the stream.
double ReadDouble()
Reads a double (IEEE encoded) from the stream.
wxString wxTextInputStream::ReadLine()
Reads a line from the input stream and returns it (without the end of line character).
wxString wxTextInputStream::ReadString()
NB: This method is deprecated, use ReadLine or ReadWord instead.
Same as ReadLine.
wxString wxTextInputStream::ReadWord()
Reads a word (a sequence of characters until the next separator) from the input stream.
See also
void SetStringSeparators(const wxString& sep)
Sets the characters which are used to define the word boundaries in ReadWord.
The default separators are the space and TAB characters.