Version: 2.9.4
Public Member Functions | Protected Member Functions
wxInputStream Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/stream.h>

Inheritance diagram for wxInputStream:

Detailed Description

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

It is the base class of all streams which provide a Read() function, i.e. which can be used to read data from a source (e.g. a file, a socket, etc).

If you want to create your own input stream, you'll need to derive from this class and implement the protected OnSysRead() function only.

Library:  wxBase
Category:  Streams

Public Member Functions

 wxInputStream ()
 Creates a dummy input stream.
virtual ~wxInputStream ()
 Destructor.
virtual bool CanRead () const
 Returns true if some data is available in the stream right now, so that calling Read() wouldn't block.
virtual bool Eof () const
 Returns true after an attempt has been made to read past the end of the stream.
int GetC ()
 Returns the first character in the input queue and removes it, blocking until it appears if necessary.
virtual size_t LastRead () const
 Returns the last number of bytes read.
virtual char Peek ()
 Returns the first character in the input queue without removing it.
virtual wxInputStreamRead (void *buffer, size_t size)
 Reads the specified amount of bytes and stores the data in buffer.
wxInputStreamRead (wxOutputStream &stream_out)
 Reads data from the input queue and stores it in the specified output stream.
virtual wxFileOffset SeekI (wxFileOffset pos, wxSeekMode mode=wxFromStart)
 Changes the stream current position.
virtual wxFileOffset TellI () const
 Returns the current stream position or wxInvalidOffset if it's not available (e.g.
size_t Ungetch (const void *buffer, size_t size)
 This function is only useful in read mode.
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.

Protected Member Functions

size_t OnSysRead (void *buffer, size_t bufsize)=0
 Internal function.

List of all members.


Constructor & Destructor Documentation

wxInputStream::wxInputStream ( )

Creates a dummy input stream.

virtual wxInputStream::~wxInputStream ( ) [virtual]

Destructor.


Member Function Documentation

virtual bool wxInputStream::CanRead ( ) const [virtual]

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

virtual bool wxInputStream::Eof ( ) const [virtual]

Returns true after an attempt has been made to read past the end of the stream.

int wxInputStream::GetC ( )

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

On success returns a value between 0 - 255; on end of file returns wxEOF.

virtual size_t wxInputStream::LastRead ( ) const [virtual]

Returns the last number of bytes read.

size_t wxInputStream::OnSysRead ( void *  buffer,
size_t  bufsize 
) [protected, pure virtual]

Internal function.

It is called when the stream wants to read data of the specified size bufsize and wants it to be placed inside buffer.

It should return the size that was actually read or zero if EOF has been reached or an error occurred (in this last case the internal m_lasterror variable should be set accordingly as well).

virtual char wxInputStream::Peek ( ) [virtual]

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

virtual wxInputStream& wxInputStream::Read ( void *  buffer,
size_t  size 
) [virtual]

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

To check if the call was successful you must use LastRead() to check if this call did actually read size bytes (if it didn't, GetLastError() should return a meaningful value).

Warning:
The buffer absolutely needs to have at least the specified size.
Returns:
This function returns a reference on the current object, so the user can test any states of the stream right away.
wxInputStream& 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.

Returns:
This function returns a reference on the current object, so the user can test any states of the stream right away.
virtual wxFileOffset wxInputStream::SeekI ( wxFileOffset  pos,
wxSeekMode  mode = wxFromStart 
) [virtual]

Changes the stream current position.

This operation in general is possible only for seekable streams (see wxStreamBase::IsSeekable()); non-seekable streams support only seeking positive amounts in mode wxFromCurrent (this is implemented by reading data and simply discarding it).

Parameters:
posOffset to seek to.
modeOne of wxFromStart, wxFromEnd, wxFromCurrent.
Returns:
The new stream position or wxInvalidOffset on error.
virtual wxFileOffset wxInputStream::TellI ( ) const [virtual]

Returns the current stream position or wxInvalidOffset if it's not available (e.g.

socket streams do not have a size nor a current stream position).

bool wxInputStream::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.

size_t wxInputStream::Ungetch ( const void *  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).

Returns:
Returns the amount of bytes saved in the Write-Back buffer.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines