Yate
Public Member Functions | Protected Attributes
MemoryStream Class Reference

A Stream that operates on DataBlocks in memory. More...

#include <yateclass.h>

Inheritance diagram for MemoryStream:
Stream

List of all members.

Public Member Functions

 MemoryStream ()
 MemoryStream (const DataBlock &data)
const DataBlockdata () const
virtual bool terminate ()
virtual bool valid () const
virtual int writeData (const void *buffer, int len)
virtual int readData (void *buffer, int len)
virtual int64_t length ()
virtual int64_t seek (SeekPos pos, int64_t offset=0)

Protected Attributes

DataBlock m_data
int64_t m_offset

Detailed Description

A Stream that operates on DataBlocks in memory.

An implementation of a Stream that reads and writes data in a DataBlock


Constructor & Destructor Documentation

MemoryStream ( ) [inline]

Constructor of an empty stream

MemoryStream ( const DataBlock data) [inline]

Constructor of aan initialized stream

Parameters:
dataInitial data to be copied in the memory stream

Member Function Documentation

const DataBlock& data ( ) const [inline]

Get read-only access to the DataBlock held

Returns:
Const reference to the DataBlock
virtual int64_t length ( ) [inline, virtual]

Get the length of the stream

Returns:
Length of the DataBlock in memory

Reimplemented from Stream.

virtual int readData ( void *  buffer,
int  len 
) [virtual]

Get data from internal DataBlock, advance pointer

Parameters:
bufferBuffer for getting the data
lenLength of the buffer
Returns:
Number of bytes read, negative on error, zero on end of data

Implements Stream.

virtual int64_t seek ( SeekPos  pos,
int64_t  offset = 0 
) [virtual]

Set the read/write pointer

Parameters:
posThe seek start as enumeration
offsetThe number of bytes to move the pointer from starting position
Returns:
The new position of the stream read/write pointer. Negative on failure

Reimplemented from Stream.

virtual bool terminate ( ) [inline, virtual]

Do-nothing termination handler

Returns:
True to signal the stream was closed

Implements Stream.

virtual bool valid ( ) const [inline, virtual]

Do-nothing validity check

Returns:
True to indicate the stream is valid

Implements Stream.

virtual int writeData ( const void *  buffer,
int  len 
) [virtual]

Write new data to the DataBlock at current position, advance pointer

Parameters:
bufferBuffer of source data
lenLength of data to be written
Returns:
Number of bytes written, negative on error

Implements Stream.


Member Data Documentation

DataBlock m_data [protected]

The DataBlock holding the data in memory

int64_t m_offset [protected]

The current position for read/write operation


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