The memory stream class. More...

#include "murl_util_memory_stream.h"

Public Member Functions

 MemoryStream ()
 The default constructor.
 
virtual ~MemoryStream ()
 The destructor.
 
virtual Bool Open (const ConstData &data)
 Open a memory stream from a data object. More...
 
virtual Bool Open (const void *data, UInt64 byteSize)
 Open a memory stream. More...
 
virtual Bool Close ()
 Close the memory stream. More...
 
Bool IsOpen () const
 Check if the memory stream is open. More...
 
virtual UInt64 GetSize () const
 Get the size of the memory stream. More...
 
virtual UInt64 GetPosition () const
 Get the current read position. More...
 
virtual void SetPosition (UInt64 position)
 Set the current read position. More...
 
virtual UInt64 Read (void *data, UInt64 byteSize)
 Read from the memory stream at the current position. More...
 
virtual Bool Eos () const
 Check if the end of the stream is reached. More...
 

Protected Attributes

ConstData mData
 Reference to the memory data. More...
 
Bool mIsOpen
 The open status. More...
 
UInt64 mCurrentOffset
 The current byte position. More...
 

Detailed Description

The memory stream class.

The MemoryStream class implements file behaviour on a memory block. The memory to read from is used by reference only, which allows using memory mapped files without copying the data to memory.

(!) The ownership of the data object's memory pointer remains to the caller. This means as long as the MemoryStream is used, the memory pointer of the data object (but probably not to data object itself) must be available in memory.

Member Function Documentation

◆ Open() [1/2]

virtual Bool Murl::Util::MemoryStream::Open ( const ConstData data)
virtual

Open a memory stream from a data object.

Parameters
dataThe data object.
Returns
true if successful.

◆ Open() [2/2]

virtual Bool Murl::Util::MemoryStream::Open ( const void *  data,
UInt64  byteSize 
)
virtual

Open a memory stream.

Parameters
dataPointer to the memory location.
byteSizeByte size of the memory location.
Returns
true if successful.

◆ Close()

virtual Bool Murl::Util::MemoryStream::Close ( )
virtual

Close the memory stream.

Returns
true if successful.

◆ IsOpen()

Bool Murl::Util::MemoryStream::IsOpen ( ) const

Check if the memory stream is open.

Returns
true if the memory stream is open.

◆ GetSize()

virtual UInt64 Murl::Util::MemoryStream::GetSize ( ) const
virtual

Get the size of the memory stream.

Returns
The byte size of the memory stream.

◆ GetPosition()

virtual UInt64 Murl::Util::MemoryStream::GetPosition ( ) const
virtual

Get the current read position.

Returns
The current read position in bytes.

◆ SetPosition()

virtual void Murl::Util::MemoryStream::SetPosition ( UInt64  position)
virtual

Set the current read position.

Parameters
positionThe current read in bytes.

◆ Read()

virtual UInt64 Murl::Util::MemoryStream::Read ( void *  data,
UInt64  byteSize 
)
virtual

Read from the memory stream at the current position.

Parameters
dataPointer to the memory to read into.
byteSizeThe byte size of the memory.
Returns
The number of bytes read from the memory stream.

◆ Eos()

virtual Bool Murl::Util::MemoryStream::Eos ( ) const
virtual

Check if the end of the stream is reached.

Returns
true if the end of the stream is reached.

Member Data Documentation

◆ mData

ConstData Murl::Util::MemoryStream::mData
protected

Reference to the memory data.

◆ mIsOpen

Bool Murl::Util::MemoryStream::mIsOpen
protected

The open status.

◆ mCurrentOffset

UInt64 Murl::Util::MemoryStream::mCurrentOffset
protected

The current byte position.


The documentation for this class was generated from the following file:
  • murl_util_memory_stream.h


Copyright © 2011-2018 Spraylight GmbH.