class MemoryStream

# class MemoryStream | A Stream that operates on DataBlocks in memory. More...
Full name | `TelEngine::MemoryStream`
Definition | `#include <yateclass.h>`
Inherits | TelEngine::Stream [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- inline MemoryStream ()
- inline MemoryStream (const DataBlock& data)
- inline const DataBlock& data () 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 Members

- DataBlock m_data
- int64_t m_offset

## Detailed Description

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

inline MemoryStream () | ### MemoryStream

Constructor of an empty stream

inline MemoryStream (const DataBlock& data) | ### MemoryStream

Constructor of aan initialized stream

Parameters:

data | Initial data to be copied in the memory stream

inline const DataBlock& data () | ### data

[const]

Get read-only access to the DataBlock held

Returns: Const reference to the DataBlock

bool terminate () | ### terminate

[virtual]

Do-nothing termination handler

Returns: True to signal the stream was closed

Reimplemented from Stream.

bool valid () | ### valid

[const virtual]

Do-nothing validity check

Returns: True to indicate the stream is valid

Reimplemented from Stream.

int writeData (const void* buffer, int len) | ### writeData

[virtual]

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

Parameters:

buffer | Buffer of source data
len | Length of data to be written

Returns: Number of bytes written, negative on error

Reimplemented from Stream.

int readData (void* buffer, int len) | ### readData

[virtual]

Get data from internal DataBlock, advance pointer

Parameters:

buffer | Buffer for getting the data
len | Length of the buffer

Returns: Number of bytes read, negative on error, zero on end of data

Reimplemented from Stream.

int64_t length () | ### length

[virtual]

Get the length of the stream

Returns: Length of the DataBlock in memory

Reimplemented from Stream.

int64_t seek (SeekPos pos, int64_t offset = 0) | ### seek

[virtual]

Set the read/write pointer

Parameters:

pos | The seek start as enumeration
offset | The 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.

DataBlock m_data | ### m_data

[protected]

int64_t m_offset | ### m_offset

[protected]

Generated by: paulc on bussard on Fri May 8 12:37:22 2015, using kdoc 2.0a54.