ezEngine Release 26.3
Loading...
Searching...
No Matches
ezMemoryStreamReader Class Reference

A reader which can access a memory stream. More...

#include <MemoryStream.h>

Inheritance diagram for ezMemoryStreamReader:

Public Member Functions

 ezMemoryStreamReader (const ezMemoryStreamStorageInterface *pStreamStorage=nullptr)
 Pass the memory storage object from which to read from. Pass nullptr if you are going to set the storage stream later via SetStorage().
 
void SetStorage (const ezMemoryStreamStorageInterface *pStreamStorage)
 Sets the storage object upon which to operate. Resets the read position to zero. Pass nullptr if you want to detach from any previous storage stream, for example to ensure its reference count gets properly reduced.
 
virtual ezUInt64 ReadBytes (void *pReadBuffer, ezUInt64 uiBytesToRead) override
 Reads either uiBytesToRead or the amount of remaining bytes in the stream into pReadBuffer.
 
virtual ezUInt64 SkipBytes (ezUInt64 uiBytesToSkip) override
 Skips bytes in the stream (e.g. for skipping objects which can't be serialized due to missing information etc.)
 
void SetReadPosition (ezUInt64 uiReadPosition)
 Sets the read position to be used.
 
ezUInt64 GetReadPosition () const
 Returns the current read position.
 
ezUInt32 GetByteCount32 () const
 Returns the total available bytes in the memory stream.
 
ezUInt64 GetByteCount64 () const
 
void SetDebugSourceInformation (ezStringView sDebugSourceInformation)
 Allows to set a string as the source of information in the memory stream for debug purposes.
 
- Public Member Functions inherited from ezStreamReader
 ezStreamReader ()
 Constructor.
 
virtual ~ezStreamReader ()
 Virtual destructor to ensure correct cleanup.
 
template<typename T >
ezResult ReadWordValue (T *pWordValue)
 Helper method to read a word value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult ReadDWordValue (T *pDWordValue)
 Helper method to read a dword value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult ReadQWordValue (T *pQWordValue)
 Helper method to read a qword value correctly (copes with potentially different endianess)
 
template<typename ArrayType , typename ValueType >
ezResult ReadArray (ezArrayBase< ValueType, ArrayType > &inout_array)
 Reads an array of elements from the stream.
 
template<typename ValueType , ezUInt16 uiSize, typename AllocatorWrapper >
ezResult ReadArray (ezSmallArray< ValueType, uiSize, AllocatorWrapper > &ref_array)
 Reads a small array of elements from the stream.
 
template<typename ValueType , ezUInt32 uiSize>
ezResult ReadArray (ValueType(&array)[uiSize])
 Writes a C style fixed array.
 
template<typename KeyType , typename Comparer >
ezResult ReadSet (ezSetBase< KeyType, Comparer > &inout_set)
 Reads a set.
 
template<typename KeyType , typename ValueType , typename Comparer >
ezResult ReadMap (ezMapBase< KeyType, ValueType, Comparer > &inout_map)
 Reads a map.
 
template<typename KeyType , typename ValueType , typename Hasher >
ezResult ReadHashTable (ezHashTableBase< KeyType, ValueType, Hasher > &inout_hashTable)
 Read a hash table (note that the entry order is not stable)
 
ezResult ReadString (ezStringBuilder &ref_sBuilder)
 Reads a string into an ezStringBuilder.
 
ezResult ReadString (ezString &ref_sString)
 Reads a string into an ezString.
 
EZ_ALWAYS_INLINE ezTypeVersion ReadVersion ()
 
EZ_ALWAYS_INLINE ezTypeVersion ReadVersion (ezTypeVersion expectedMaxVersion)
 

Detailed Description

A reader which can access a memory stream.

MemoryStreamReader provides sequential reading access to data stored in any MemoryStreamStorageInterface implementation. It maintains an internal read position and supports both forward reading and seeking.

Thread safety:

  • NOT thread-safe - each thread requires its own reader instance
  • Multiple readers can safely share the same storage concurrently
  • Concurrent reading and writing to the same storage is unsafe

Member Function Documentation

◆ ReadBytes()

ezUInt64 ezMemoryStreamReader::ReadBytes ( void *  pReadBuffer,
ezUInt64  uiBytesToRead 
)
overridevirtual

Reads either uiBytesToRead or the amount of remaining bytes in the stream into pReadBuffer.

It is valid to pass nullptr for pReadBuffer, in this case the memory stream position is only advanced by the given number of bytes.

Implements ezStreamReader.

◆ SkipBytes()

ezUInt64 ezMemoryStreamReader::SkipBytes ( ezUInt64  uiBytesToSkip)
overridevirtual

Skips bytes in the stream (e.g. for skipping objects which can't be serialized due to missing information etc.)

Reimplemented from ezStreamReader.


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