Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BlockInStream Class Reference

#include <elm/io/BlockInStream.h>

+ Inheritance diagram for BlockInStream:

Public Member Functions

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

Additional Inherited Members

- Static Public Attributes inherited from 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

◆ BlockInStream() [1/4]

BlockInStream ( const void block,
int  size 
)

Build a new memory block input stream.

Parameters
blockBlock to read from.
sizeBlock size.

◆ BlockInStream() [2/4]

BlockInStream ( const char *  str)

Build a block input stream from a C string.

Parameters
strC string to read.

References elm::str().

◆ BlockInStream() [3/4]

BlockInStream ( const CString str)

Build a block input stream from a CString object.

Parameters
strString to read to.

◆ BlockInStream() [4/4]

BlockInStream ( const String str)

Build a block input stream from a String object.

Parameters
strString to read from.

Member Function Documentation

◆ block()

char * block ( ) const
inline

Get the current memory block.

Returns
Memory block.

◆ mark()

int mark ( ) const
inline

Get the current offset in the memory block.

Returns
Current offset.

Referenced by BlockInStream::move().

◆ move()

void move ( int  mark)
inline

Move the read position to the given mark.

Parameters
markPosition mark to move to.

References BlockInStream::mark().

◆ moveBackward()

void moveBackward ( int  size)
inline

Move backward in the stream.

Parameters
sizeCount of bytes to move backward to.

References BlockInStream::size().

◆ moveForward()

void moveForward ( int  size)
inline

Move forward in the stream.

Parameters
sizeCount of bytes to move forward to.

References BlockInStream::size().

◆ read() [1/2]

int read ( )
overridevirtual

Read one byte from the stream.

Returns
Read byte, FAILED for an error, ENDED for end of stream.

Reimplemented from InStream.

References InStream::ENDED.

◆ read() [2/2]

int read ( void buffer,
int  size 
)
overridevirtual

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 InStream.

References BlockInStream::size().

◆ reset()

void reset ( void  )
inline

Reset the stream to the start.

◆ size()

int size ( ) const
inline

Get the size of the current memory block.

Returns
Memory block size.

Referenced by BlockInStream::moveBackward(), BlockInStream::moveForward(), and BlockInStream::read().


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