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

Stream reader that parses chunked data written by ezChunkStreamWriter. More...

#include <ChunkStream.h>

Inheritance diagram for ezChunkStreamReader:

Classes

struct  ChunkInfo
 Metadata and status information for the current chunk. More...
 

Public Types

enum class  EndChunkFileMode { SkipToEnd , JustClose }
 Controls how the reader behaves when ending the chunk file. More...
 

Public Member Functions

 ezChunkStreamReader (ezStreamReader &inout_stream)
 Pass the underlying stream writer to the constructor.
 
virtual ezUInt64 ReadBytes (void *pReadBuffer, ezUInt64 uiBytesToRead) override
 Reads data from the current chunk.
 
void SetEndChunkFileMode (EndChunkFileMode mode)
 
virtual ezUInt16 BeginStream ()
 Initializes reading and returns the stream format version.
 
virtual void EndStream ()
 Stops reading from the chunk file. Optionally skips the remaining bytes, so that the underlying streams read position is after the chunk file content.
 
const ChunkInfoGetCurrentChunk () const
 Returns information about the current chunk.
 
void NextChunk ()
 Skips the rest of the current chunk and starts reading the next chunk.
 
- 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.
 
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

Stream reader that parses chunked data written by ezChunkStreamWriter.

This reader provides sequential access to chunks within a stream, allowing selective reading based on chunk names and versions. Each chunk can be read completely or skipped entirely. The reader tracks chunk boundaries automatically and provides metadata about each chunk. Use BeginStream/EndStream to initialize and cleanup, then iterate through chunks with NextChunk().

Member Enumeration Documentation

◆ EndChunkFileMode

Controls how the reader behaves when ending the chunk file.

Enumerator
SkipToEnd 

Makes sure all data is properly read, so that the stream read position is after the chunk file data. Useful if the chunk file is embedded in another file stream.

JustClose 

Just stops, leaving the stream at the last read position. This should be used if definitely nothing more needs to be read from all underlying streams.

Member Function Documentation

◆ BeginStream()

ezUInt16 ezChunkStreamReader::BeginStream ( )
virtual

Initializes reading and returns the stream format version.

Returns the version number that was passed to ezChunkStreamWriter::BeginStream(). Use this version for compatibility checking before processing chunks.

◆ ReadBytes()

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

Reads data from the current chunk.

Only allowed while a valid chunk is available. Returns 0 bytes when the end of a chunk is reached, even if there are more chunks to come. Use NextChunk() to advance to the next chunk.

Implements ezStreamReader.


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