Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::io::BlockInStream Class Reference

#include <elm/io/BlockInStream.h>

+ Inheritance diagram for elm::io::BlockInStream:

Public Member Functions

 BlockInStream (const void *block, int size)
 
 BlockInStream (const char *str)
 
 BlockInStream (const CString &str)
 
 BlockInStream (const String &str)
 
const void * block (void) const
 
int size (void) const
 
int mark (void) const
 
void move (int mark)
 
void moveForward (int size)
 
void moveBackward (int size)
 
void reset (void)
 
virtual int read (void *buffer, int size)
 
virtual int read (void)
 
- Public Member Functions inherited from elm::io::InStream
virtual ~InStream (void)
 
virtual CString lastErrorMessage (void)
 

Additional Inherited Members

- Static Public Attributes inherited from elm::io::InStream
static const int FAILED = -1
 
static const int ENDED = -2
 
static InStreamnull = _null
 

Detailed Description

Input stream from a memory block.

Constructor & Destructor Documentation

elm::io::BlockInStream::BlockInStream ( const void *  block,
int  size 
)

Build a new memory block input stream.

Parameters
blockBlock to read from.
sizeBlock size.
elm::io::BlockInStream::BlockInStream ( const char *  str)

Build a block input stream from a C string.

Parameters
strC string to read.
elm::io::BlockInStream::BlockInStream ( const CString str)

Build a block input stream from a CString object.

Parameters
strString to read to.
elm::io::BlockInStream::BlockInStream ( const String str)

Build a block input stream from a String object.

Parameters
strString to read from.

Member Function Documentation

char * elm::io::BlockInStream::block ( void  ) const

Get the current memory block.

Returns
Memory block.
int elm::io::BlockInStream::mark ( void  ) const

Get the current offset in the memory block.

Returns
Current offset.

Referenced by move().

void elm::io::BlockInStream::move ( int  mark)

Move the read position to the given mark.

Parameters
markPosition mark to move to.

References mark().

void elm::io::BlockInStream::moveBackward ( int  size)

Move backward in the stream.

Parameters
sizeCount of bytes to move backward to.

References size().

void elm::io::BlockInStream::moveForward ( int  size)

Move forward in the stream.

Parameters
sizeCount of bytes to move forward to.
int elm::io::BlockInStream::read ( void *  buffer,
int  size 
)
virtual

Read some bytes from the stream and store them in the given buffer. This method does not ever read as many bytes as available in the buffer even if the stream is not ended. Insteadn a read returning 0 bytes means the end of stream is reached.

Parameters
bufferBuffer to write bytes in.
sizeSize of the buffer.
Returns
Number of read bytes, 0 for end of stream, -1 for an error.

Implements elm::io::InStream.

References size().

int elm::io::BlockInStream::read ( void  )
virtual

Read one byte from the stream.

Returns
Read byte, ERROR for an error, END for end of stream.

Reimplemented from elm::io::InStream.

References elm::io::InStream::ENDED.

void elm::io::BlockInStream::reset ( void  )

Reset the stream to the start.

int elm::io::BlockInStream::size ( void  ) const

Get the size of the current memory block.

Returns
Memory block size.

Referenced by moveBackward(), and read().


The documentation for this class was generated from the following files: