Base Framework
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ZLibDeflater Class Reference

ZLIB deflater. More...

#include <base/compression/ZLibDeflater.h>

Inherits Object, and Deflater.

Public Member Functions

 ZLibDeflater ()
 
 ZLibDeflater (unsigned int compressionLevel)
 
bool atEnd () const noexcept
 
void flush ()
 
MemorySize push (const uint8 *buffer, MemorySize size)
 
void pushEnd ()
 
MemorySize pull (uint8 *buffer, MemorySize size)
 
virtual ~ZLibDeflater () noexcept
 
- Public Member Functions inherited from PushInterface
virtual bool pushBegin (uint64 totalSize)
 

Static Public Member Functions

static bool isSupported () noexcept
 

Static Public Attributes

static const unsigned int BUFFER_SIZE = 64 * 1024
 
static const unsigned int DEFAULT_COMPRESSION_LEVEL = 6
 

Detailed Description

ZLIB deflater.

ZLIB deflater push stream.

Version
1.0

Constructor & Destructor Documentation

◆ ZLibDeflater() [1/2]

ZLibDeflater::ZLibDeflater ( )

Initializes the deflater with the default compression level.

◆ ZLibDeflater() [2/2]

ZLibDeflater::ZLibDeflater ( unsigned int  compressionLevel)

Initializes the deflater with the specified compression level.

Parameters
compressionLevelThe compression level.

◆ ~ZLibDeflater()

virtual ZLibDeflater::~ZLibDeflater ( )
virtualnoexcept

Destroys the deflater.

Member Function Documentation

◆ atEnd()

bool ZLibDeflater::atEnd ( ) const
inlinevirtualnoexcept

Returns true if the end has been reached. This always returns false until pushEnd() has been invoked.

Implements Deflater.

◆ flush()

void ZLibDeflater::flush ( )
virtual

Flushes the stream. Invoke pull() one or more times to read the compressed data. The stream has been flushed when pull() returns 0.

Implements Deflater.

◆ isSupported()

static bool ZLibDeflater::isSupported ( )
staticnoexcept

Returns true if ZLib is supported by the runtime.

◆ pull()

MemorySize ZLibDeflater::pull ( uint8 *  buffer,
MemorySize  size 
)
virtual

Pulls compressed bytes from the stream. EndOfFile is raised if atEnd() would return true. This method may return 0 in the normal deflation mode if the internal buffer is not full. Use flush() to force any buffered data through the pull() interface. Flush is completed when pull() returns 0.

Parameters
bufferThe buffer to receive the compressed data.
sizeThe size of the buffer.
Returns
The number of bytes pulled.

Implements PullInterface.

◆ push()

MemorySize ZLibDeflater::push ( const uint8 *  buffer,
MemorySize  size 
)
virtual

Pushes uncompressed data onto the stream. This method may return 0 if the internal buffer is full. EndOfFile is raised if the end has been reached. IOException is raised unless the deflater is in the normal compression mode.

Parameters
bufferThe data to be pushed onto the stream.
sizeThe size of the buffer.
Returns
The number of bytes pushed.

Implements PushInterface.

◆ pushEnd()

void ZLibDeflater::pushEnd ( )
virtual

This method should be invoked when all uncompressed data has been pushed onto the stream. Do not invoke flush(), push(), or pushEnd() hereafter.

Reimplemented from PushInterface.

Member Data Documentation

◆ BUFFER_SIZE

const unsigned int ZLibDeflater::BUFFER_SIZE = 64 * 1024
static

The size of the compression buffer.

◆ DEFAULT_COMPRESSION_LEVEL

const unsigned int ZLibDeflater::DEFAULT_COMPRESSION_LEVEL = 6
static

The default compression level.