1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // EZLib: COMPRESSOR.H
15 // Declaration for Compression class
19 #ifndef __EZCOMPRESSOR_H__
20 #define __EZCOMPRESSOR_H__
27 The CEZCompressor class provides in-memory compression functions, including integrity checks of the uncompressed data.
28 This version of the library supports only one compression method (deflation). Compression can be done in a single step
29 (using CompressL()) if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls
30 of the DeflateL() function. The source data is compressed to the target buffer (both source and target contained within
31 the buffer manager argument), and various other arguments distinguish the different compression settings.
36 class CEZCompressor : public CEZZStream
39 /** Compression strategy - used to tune the compression algorithm */
42 /** Use for normal data */
43 EDefaultStrategy = Z_DEFAULT_STRATEGY,
45 /** Force Huffman encoding only (no string match) */
46 EFiltered = Z_FILTERED,
48 /** Use for data produced by a filter (or predictor) */
49 EHuffmanOnly = Z_HUFFMAN_ONLY
52 /** Compression levels */
55 EDefaultCompression = Z_DEFAULT_COMPRESSION,
56 ENoCompression = Z_NO_COMPRESSION,
57 EBestSpeed = Z_BEST_SPEED,
58 EBestCompression = Z_BEST_COMPRESSION
61 /** Window Bits - the base two logarithm of the window size (the size of the history buffer) */
67 /** Memory level - specifies how much memory should be allocated for the internal compression state */
70 EDefMemLevel = MAX_MEM_LEVEL
73 /** Compression panic values */
76 EDeflateInitlialiserError = EUnexpected + 1,
83 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
84 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
85 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, TInt aLevel = EDefaultCompression,
86 TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
87 IMPORT_C static CEZCompressor* NewLC(MEZBufferManager& aInit, const TDesC8 &aDictionary,
88 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel,
89 TStrategy aStrategy = EDefaultStrategy);
90 IMPORT_C static CEZCompressor* NewL(MEZBufferManager& aInit, const TDesC8 &aDictionary,
91 TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel,
92 TStrategy aStrategy = EDefaultStrategy);
94 IMPORT_C void ResetL(MEZBufferManager& aInit);
96 IMPORT_C TBool DeflateL();
98 IMPORT_C static void CompressL(TDes8 &aDestination, const TDesC8 &aSource, TInt aLevel = EDefaultCompression);
110 CEZCompressor(MEZBufferManager* aInit);
111 void ConstructL(TInt aLevel, const TUint8* aDictionary, TInt aLength, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
112 void ConstructL(TInt aLevel, TInt aWindowBits, TInt aMemLevel, TStrategy aStrategy);
115 MEZBufferManager* iBufferInit;
116 TDeflationState iDeflationState;