ezEngine Release 26.3
Loading...
Searching...
No Matches
ezStreamReader Class Referenceabstract

Abstract base class for binary input streams providing unified reading interface. More...

#include <Stream.h>

Inheritance diagram for ezStreamReader:

Public Member Functions

 ezStreamReader ()
 Constructor.
 
virtual ~ezStreamReader ()
 Virtual destructor to ensure correct cleanup.
 
virtual ezUInt64 ReadBytes (void *pReadBuffer, ezUInt64 uiBytesToRead)=0
 Reads a raw number of bytes into the read buffer. This is the only method that must be implemented by derived classes.
 
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.
 
virtual ezUInt64 SkipBytes (ezUInt64 uiBytesToSkip)
 Helper method to skip a number of bytes (implementations of the stream reader may implement this more efficiently for example)
 
EZ_ALWAYS_INLINE ezTypeVersion ReadVersion ()
 
EZ_ALWAYS_INLINE ezTypeVersion ReadVersion (ezTypeVersion expectedMaxVersion)
 

Detailed Description

Abstract base class for binary input streams providing unified reading interface.

StreamReader defines the fundamental interface for reading binary data from various sources including files, memory buffers, network connections, and compressed streams. All read operations are performed in a sequential manner with automatic endianness handling.

Core functionality:

  • ReadBytes(): Raw binary data reading (pure virtual, must be implemented)
  • Typed reading methods with endianness conversion (ReadWordValue, ReadDWordValue, etc.)
  • High-level container reading (arrays, sets, maps, hash tables)
  • String reading with automatic length handling

Implementation requirements:

  • Derived classes must implement ReadBytes() as the primary read method
  • All other methods are implemented in terms of ReadBytes()
  • Should handle EOF conditions gracefully by returning actual bytes read

Member Function Documentation

◆ ReadBytes()

virtual ezUInt64 ezStreamReader::ReadBytes ( void *  pReadBuffer,
ezUInt64  uiBytesToRead 
)
pure virtual

Reads a raw number of bytes into the read buffer. This is the only method that must be implemented by derived classes.

Parameters
pReadBufferDestination buffer for the read data
uiBytesToReadMaximum number of bytes to read
Returns
Actual number of bytes read (may be less than requested on EOF or error)

Implemented in ezChunkStreamReader, ezFileReader, ezMemoryStreamReader, ezRawMemoryStreamReader, and ezStreamReaderWithStats.

◆ SkipBytes()

virtual ezUInt64 ezStreamReader::SkipBytes ( ezUInt64  uiBytesToSkip)
inlinevirtual

Helper method to skip a number of bytes (implementations of the stream reader may implement this more efficiently for example)

Reimplemented in ezFileReader, ezMemoryStreamReader, ezRawMemoryStreamReader, and ezStreamReaderWithStats.


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