## wxInputStream

wxInputStream is an abstract base class which may not be used directly.

Derived from

wxStreamBase

Include files

<wx/stream.h>

Members

wxInputStream::wxInputStream
wxInputStream::~wxInputStream
wxInputStream::CanRead
wxInputStream::GetC
wxInputStream::Eof
wxInputStream::LastRead
wxInputStream::Peek
wxInputStream::Read
wxInputStream::SeekI
wxInputStream::TellI
wxInputStream::Ungetch

### wxInputStream::wxInputStream

wxInputStream()

Creates a dummy input stream.

### wxInputStream::~wxInputStream

~wxInputStream()

Destructor.

### wxInputStream::CanRead

bool CanRead() const

Returns true if some data is available in the stream right now, so that calling Read() wouldn't block.

### wxInputStream::GetC

char GetC()

Returns the first character in the input queue and removes it, blocking until it appears if necessary.

Note

If EOF, return value is undefined and LastRead() will return 0 and not 1.

### wxInputStream::Eof

bool Eof() const

Returns true if the end of stream has been reached.

Note

For some streams Eof() will not return true until an attempt has been made to read past the end of the stream. LastRead() should be called after each read to check that a non-zero number of bytes have been read.

### wxInputStream::LastRead

size_t LastRead() const

Returns the last number of bytes read.

### wxInputStream::Peek

char Peek()

Returns the first character in the input queue without removing it.

Note

Blocks until something appears in the stream if necessary, if nothing ever does (i.e. EOF) LastRead() will return 0 (and the return value is undefined), otherwise LastRead() returns 1.

### wxInputStream::Read

wxInputStream& Read(void *buffer, size_t size)

Reads the specified amount of bytes and stores the data in buffer.

Warning

The buffer absolutely needs to have at least the specified size.

Return value

This function returns a reference on the current object, so the user can test any states of the stream right away.

wxInputStream& Read(wxOutputStream& stream_out)

Reads data from the input queue and stores it in the specified output stream. The data is read until an error is raised by one of the two streams.

Return value

This function returns a reference on the current object, so the user can test any states of the stream right away.

### wxInputStream::SeekI

off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart)

Changes the stream current position.

Parameters

pos

Offset to seek to.

mode

One of wxFromStart, wxFromEnd, wxFromCurrent.

Return value

The new stream position or wxInvalidOffset on error.

### wxInputStream::TellI

off_t TellI() const

Returns the current stream position.

### wxInputStream::Ungetch

size_t Ungetch(const char* buffer, size_t size)

This function is only useful in read mode. It is the manager of the "Write-Back" buffer. This buffer acts like a temporary buffer where data which has to be read during the next read IO call are put. This is useful when you get a big block of data which you didn't want to read: you can replace them at the top of the input queue by this way.

Be very careful about this call in connection with calling SeekI() on the same stream. Any call to SeekI() will invalidate any previous call to this method (otherwise you could SeekI() to one position, "unread" a few bytes there, SeekI() to another position and data would be either lost or corrupted).

Return value

Returns the amount of bytes saved in the Write-Back buffer.

bool Ungetch(char c)

This function acts like the previous one except that it takes only one character: it is sometimes shorter to use than the generic function.