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

BZip2 deflater. More...

#include <base/compression/BZip2Deflater.h>

Inherits Object, and Deflater.

Public Member Functions

 BZip2Deflater ()
 
 BZip2Deflater (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 ~BZip2Deflater ()
 
- 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 = 4
 

Detailed Description

BZip2 deflater.

BZip2 deflater push stream.

Version
1.0

Constructor & Destructor Documentation

◆ BZip2Deflater() [1/2]

BZip2Deflater::BZip2Deflater ( )

Initializes the deflater with the default compression level.

◆ BZip2Deflater() [2/2]

BZip2Deflater::BZip2Deflater ( unsigned int  compressionLevel)

Initializes the deflater with the specified compression level.

Parameters
compressionLevelThe compression level.

◆ ~BZip2Deflater()

virtual BZip2Deflater::~BZip2Deflater ( )
virtual

Destroys the deflater.

Member Function Documentation

◆ atEnd()

bool BZip2Deflater::atEnd ( ) const
inlinevirtualnoexcept

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

Implements Deflater.

◆ flush()

void BZip2Deflater::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 BZip2Deflater::isSupported ( )
staticnoexcept

Returns true if BZip2 is supported by the runtime.

◆ pull()

MemorySize BZip2Deflater::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 BZip2Deflater::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 BZip2Deflater::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 BZip2Deflater::BUFFER_SIZE = 64 * 1024
static

The size of the compression buffer.

◆ DEFAULT_COMPRESSION_LEVEL

const unsigned int BZip2Deflater::DEFAULT_COMPRESSION_LEVEL = 4
static

The default compression level.