## wxTextInputStream

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 line

Include 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::wxTextInputStream

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

The input stream.

### wxTextInputStream::~wxTextInputStream

~wxTextInputStream()

Destroys the wxTextInputStream object.

### wxTextInputStream::Read8

wxUint8 Read8()

Reads a single byte from the stream.

### wxTextInputStream::Read16

wxUint16 Read16()

Reads a 16 bit integer from the stream.

### wxTextInputStream::Read32

wxUint32 Read32()

Reads a 32 bit integer from the stream.

### wxTextInputStream::ReadDouble

double ReadDouble()

Reads a double (IEEE encoded) from the stream.

### wxTextInputStream::ReadLine

wxString wxTextInputStream::ReadLine()

Reads a line from the input stream and returns it (without the end of line character).

### wxTextInputStream::ReadString

wxString wxTextInputStream::ReadString()

NB: This method is deprecated, use ReadLine or ReadWord instead.

Same as ReadLine.

### wxTextInputStream::ReadWord

wxString wxTextInputStream::ReadWord()

Reads a word (a sequence of characters until the next separator) from the input stream.

See also

SetStringSeparators

### wxTextInputStream::SetStringSeparators

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.