CEZCompressor Class Reference

#include <ezcompressor.h>

class CEZCompressor : public CEZZStream

Inherits from

Detailed Description

The CEZCompressor class provides in-memory compression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation). Compression can be done in a single step (using CompressL()) if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls of the DeflateL() function. The source data is compressed to the target buffer (both source and target contained within the buffer manager argument), and various other arguments distinguish the different compression settings.

Note: In this version of the library a windowBits value of 8 is unsupported due to a problem with the window size being set to 256 bytes. Although a value of 8 will be accepted by the CEZCompressor constructors, as it is being changed internally by Zlib from 8 to 9, it will not be possible to use the same value for decompression. This is because the Zlib functions called by the CEZDecompressor constructors do not make the same change internally and as a result a KEZlibErrData is returned when calling InflateL(). It is therefore advised that for this version of the library windowBits of 9 is used in place of 8.

Member Enumeration Documentation

Enum anonymous

Compression levels

EnumeratorValueDescription
EDefaultCompressionZ_DEFAULT_COMPRESSION
ENoCompressionZ_NO_COMPRESSION
EBestSpeedZ_BEST_SPEED
EBestCompressionZ_BEST_COMPRESSION

Enum anonymous

Window Bits - the base two logarithm of the window size (the size of the history buffer)

EnumeratorValueDescription
EMaxWBitsMAX_WBITS

Enum anonymous

Memory level - specifies how much memory should be allocated for the internal compression state

EnumeratorValueDescription
EDefMemLevelMAX_MEM_LEVEL

Enum anonymous

Compression panic values

EnumeratorValueDescription
EDeflateInitlialiserErrorEUnexpected + 1
EDeflateTerminated

Enum TStrategy

Compression strategy - used to tune the compression algorithm

EnumeratorValueDescription
EDefaultStrategyZ_DEFAULT_STRATEGY

Use for normal data

EFilteredZ_FILTERED

Use for data produced by a filter (or predictor)

EHuffmanOnlyZ_HUFFMAN_ONLY

Force Huffman encoding only (no string match)

Constructor & Destructor Documentation

~CEZCompressor ( )

~CEZCompressor()

Member Function Documentation

CompressL ( TDes8 &, const TDesC8 &, TInt )

IMPORT_C voidCompressL(TDes8 &aDestination,
const TDesC8 &aSource,
TIntaLevel = EDefaultCompression
)[static]

Compresses the data in the given buffer

Parameters
aDestinationthe target buffer for the compressed data
aSourcethe buffer containing the data to be compressed
aLevelthe level of compression
Leave Codes
KEZLibErrBufThere is a problem with the buffer
KEZLIbErrStreamThere is a problem with the stream
...Any of the system wide error codes

DeflateL ( )

IMPORT_C TBoolDeflateL()

Compress the data to the buffer in stages, return value indicates if the compression has finalised or if further calls are necessary

Return Value
ETrue if the function must be called again, EFalse if compression is finalised
Leave Codes
KEZlibErrStreamThere is a problem with the stream
KEZlibErrBufThere is a problem with the buffer
KEZlibErrUnexpectedUnexpected programming error
...Any of the System wide error codes

NewL ( MEZBufferManager &, TInt, TInt, TInt, TStrategy )

IMPORT_C CEZCompressor *NewL(MEZBufferManager &aInit,
TIntaLevel = EDefaultCompression,
TIntaWindowBits = EMaxWBits,
TIntaMemLevel = EDefMemLevel,
TStrategyaStrategy = EDefaultStrategy
)[static]

Creates a new CEZCompressor object

See also: TStrategy

Parameters
aInitbuffer manager to handle both input and output buffers
aLevelcompression levels
aWindowBitsthe base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage.
aMemLevelspecifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed.
aStrategycompression strategy - used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately
Return Value
the new CEZCompressor object

NewL ( MEZBufferManager &, const TDesC8 &, TInt, TInt, TInt, TStrategy )

IMPORT_C CEZCompressor *NewL(MEZBufferManager &aInit,
const TDesC8 &aDictionary,
TIntaLevel = EDefaultCompression,
TIntaWindowBits = EMaxWBits,
TIntaMemLevel = EDefMemLevel,
TStrategyaStrategy = EDefaultStrategy
)[static]

Overload of CEZCompressor constructor takes aDictionary argument

See also: TStrategy

Parameters
aInitbuffer manager to handle both input and output buffers
aDictionaryused to initialize the compression dictionary from the given byte sequence without producing any compressed output. The compressor and decompressor must use exactly the same dictionary. The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary.
aLevelcompression level
aWindowBitsthe base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage.
aMemLevelspecifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed.
aStrategycompression strategy - used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately
Return Value
the new CEZCompressor object

NewLC ( MEZBufferManager &, TInt, TInt, TInt, TStrategy )

IMPORT_C CEZCompressor *NewLC(MEZBufferManager &aInit,
TIntaLevel = EDefaultCompression,
TIntaWindowBits = EMaxWBits,
TIntaMemLevel = EDefMemLevel,
TStrategyaStrategy = EDefaultStrategy
)[static]

Creates a new CEZCompressor object and leaves it on the CleanupStack

See also: TStrategy

Parameters
aInitbuffer manager to handle both input and output buffers
aLevelcompression levels
aWindowBitsthe base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage.
aMemLevelspecifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed.
aStrategycompression strategy - used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately
Return Value
the new CEZCompressor object (on the CleanupStack)

NewLC ( MEZBufferManager &, const TDesC8 &, TInt, TInt, TInt, TStrategy )

IMPORT_C CEZCompressor *NewLC(MEZBufferManager &aInit,
const TDesC8 &aDictionary,
TIntaLevel = EDefaultCompression,
TIntaWindowBits = EMaxWBits,
TIntaMemLevel = EDefMemLevel,
TStrategyaStrategy = EDefaultStrategy
)[static]

Overload of CEZCompressor constructor takes aDictionary argument

See also: TStrategy

Parameters
aInitbuffer manager to handle both input and output buffers
aDictionaryused to initialize the compression dictionary from the given byte sequence without producing any compressed output. The compressor and decompressor must use exactly the same dictionary. The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary.
aLevelcompression level
aWindowBitsthe base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage.
aMemLevelspecifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed.
aStrategycompression strategy - used to tune the compression algorithm. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately
Return Value
the new CEZCompressor object (on the CleanupStack)

ResetL ( MEZBufferManager & )

IMPORT_C voidResetL(MEZBufferManager &aInit)

Resets the current compression operation, with the new buffer manager

Parameters
aInitnew buffer manager to handle the new input and output buffers
Leave Codes
...Any of the system wide error codes