Yate: MemoryStream Class Reference

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:

## Public Member Functions
| MemoryStream ()
| MemoryStream (const DataBlock &data)
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)
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() [1/2]

MemoryStream | ( |  | ) |
| inline

Constructor of an empty stream

## ◆ MemoryStream() [2/2]

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

Constructor of aan initialized stream

Parameters

  data | Initial data to be copied in the memory stream

## Member Function Documentation

## ◆ data()

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

Get read-only access to the DataBlock held

Returns
  Const reference to the DataBlock

## ◆ length()

virtual int64_t length | ( |  | ) |
| inlinevirtual

Get the length of the stream

Returns
  Length of the DataBlock in memory

Reimplemented from Stream.

## ◆ readData()

virtual int readData | ( | void * | buffer,
|  | int | len )
| 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

Implements Stream.

## ◆ seek()

virtual int64_t seek | ( | SeekPos | pos,
|  | int64_t | offset = 0 )
| 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.

## ◆ terminate()

virtual bool terminate | ( |  | ) |
| inlinevirtual

Do-nothing termination handler

Returns
  True to signal the stream was closed

Implements Stream.

## ◆ valid()

virtual bool valid | ( |  | ) | const
| inlinevirtual

Do-nothing validity check

Returns
  True to indicate the stream is valid

Implements Stream.

## ◆ writeData()

virtual int writeData | ( | const void * | buffer,
|  | int | len )
| 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

Implements Stream.

## Member Data Documentation

## ◆ m_data

DataBlock m_data
| protected

The DataBlock holding the data in memory

## ◆ m_offset

int64_t m_offset
| protected

The current position for read/write operation

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

- yateclass.h