Yate
Public Member Functions | Protected Attributes | List of all members
MemoryStream Class Reference

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

#include <yateclass.h>

Inheritance diagram for MemoryStream:
Stream

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)
 
- Public Member Functions inherited from Stream
virtual ~Stream ()
 
int error () const
 
virtual bool canRetry () const
 
virtual bool inProgress () const
 
virtual bool setBlocking (bool block=true)
 
int writeData (const char *str)
 
int writeData (const String &str)
 
int writeData (const DataBlock &buf)
 
int64_t seek (int64_t offset)
 

Protected Attributes

DataBlock m_data
 
int64_t m_offset
 
- Protected Attributes inherited from Stream
int m_error
 

Additional Inherited Members

- Public Types inherited from Stream
enum  SeekPos { SeekBegin, SeekEnd, SeekCurrent }
 
- Static Public Member Functions inherited from Stream
static bool allocPipe (Stream *&reader, Stream *&writer)
 
static bool allocPair (Stream *&str1, Stream *&str2)
 
static bool supportsPipes ()
 
static bool supportsPairs ()
 
- Protected Member Functions inherited from Stream
 Stream ()
 
void clearError ()
 

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

References MemoryStream::m_data.

virtual int64_t length ( )
inlinevirtual

Get the length of the stream

Returns
Length of the DataBlock in memory

Reimplemented from Stream.

References DataBlock::length(), and MemoryStream::m_data.

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 ( )
inlinevirtual

Do-nothing termination handler

Returns
True to signal the stream was closed

Implements Stream.

virtual bool valid ( ) const
inlinevirtual

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

Referenced by MemoryStream::data(), and MemoryStream::length().

int64_t m_offset
protected

The current position for read/write operation


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