MemStream

Engine/source/core/stream/memStream.h

The MemStream class is used to read and write to a memory buffer.

More...

Private Types

Parent 

Protected Attributes

void *

The memory buffer.

The actual size of the memory buffer.

Our current read/write position within the buffer.

The amount to grow the buffer when we run out of space writing to the stream.

bool

If true the memory is owned by the steam and it will be deleted in the destructor.

The size of the data in the stream.

Public Functions

MemStream(U32 bufferSize, void * buffer, bool allowRead, bool allowWrite)

This constructs the stream with a fixed size memory buffer.

MemStream(U32 growSize, bool allowRead, bool allowWrite)

This constructs an empty memory stream that will grow in increments as needed.

The destructor.

void *

Returns the memory buffer.

Gets the position in the stream.

Gets the size of the stream.

bool

Checks to see if this stream has the capability of a given function.

bool
setPosition(const U32 in_newPosition)

Sets the position of the stream. Returns if the new position is valid or not.

void *

Takes the memory buffer reseting the stream.

Protected Functions

bool
_read(const U32 in_numBytes, void * out_pBuffer)
bool
_write(const U32 in_numBytes, const void * in_pBuffer)

Detailed Description

The MemStream class is used to read and write to a memory buffer.

Private Types

typedef Stream Parent 

Protected Attributes

void * mBufferBase 

The memory buffer.

U32 mBufferSize 

The actual size of the memory buffer.

It is always greater than or equal to the mStreamSize.

U32 mCurrentPosition 

Our current read/write position within the buffer.

U32 mGrowSize 

The amount to grow the buffer when we run out of space writing to the stream.

U32 mInstCaps 
bool mOwnsMemory 

If true the memory is owned by the steam and it will be deleted in the destructor.

U32 mStreamSize 

The size of the data in the stream.

It is always less than or equal to the mBufferSize.

Public Functions

MemStream(U32 bufferSize, void * buffer, bool allowRead, bool allowWrite)

This constructs the stream with a fixed size memory buffer.

If buffer is null then it will be allocated for you.

MemStream(U32 growSize, bool allowRead, bool allowWrite)

This constructs an empty memory stream that will grow in increments as needed.

~MemStream()

The destructor.

getBuffer()

Returns the memory buffer.

getBuffer()

getPosition()

Reimplemented from: Stream

getStreamSize()

Reimplemented from: Stream

hasCapability(const Capability caps)

Reimplemented from: Stream

setPosition(const U32 in_newPosition)

Reimplemented from: Stream

takeBuffer()

Takes the memory buffer reseting the stream.

Protected Functions

_read(const U32 in_numBytes, void * out_pBuffer)

Reimplemented from: Stream

_write(const U32 in_numBytes, const void * in_pBuffer)

Reimplemented from: Stream