ezEngine  Milestone 7
ezCompressedStreamReader Class Reference

A stream reader that will decompress data that was stored using the ezCompressedStreamWriter. More...

#include <CompressedStream.h>

Inheritance diagram for ezCompressedStreamReader:

Public Member Functions

 ezCompressedStreamReader (ezStreamReaderBase &InputStream)
 Takes an input stream as the source from which to read the compressed data.
 
virtual ezUInt64 ReadBytes (void *pReadBuffer, ezUInt64 uiBytesToRead) override
 Reads either uiBytesToRead or the amount of remaining bytes in the stream into pReadBuffer. More...
 
- Public Member Functions inherited from ezStreamReaderBase
 ezStreamReaderBase ()
 Constructor.
 
virtual ~ezStreamReaderBase ()
 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)
 
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)
 

Private Attributes

bool m_bReachedEnd
 
ezUInt8 m_CompressedCache [256]
 
ezStreamReaderBasem_InputStream
 
z_stream_s * m_pZLibStream
 

Detailed Description

A stream reader that will decompress data that was stored using the ezCompressedStreamWriter.

The reader takes another reader as its data source (e.g. a file or a memory stream). The compressed reader uses a cache of 256 Bytes internally to prevent excessive reads from its source and to improve decompression speed. Note that currently neither ezCompressedStreamReader nor ezCompressedStreamWriter are able to handle streams that are larger than 4 GB.

Member Function Documentation

ezUInt64 ezCompressedStreamReader::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. However, since this is a compressed stream, the decompression still needs to be done, so this won't save any time.

Implements ezStreamReaderBase.


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