compressionlibs/ziplib/inc/ezdecompressor.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Declaration for Decompression class
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __EZDECOMPRESSOR_H__
       
    19 #define __EZDECOMPRESSOR_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <ezstream.h>
       
    23 #include <ezbufman.h>
       
    24 
       
    25 /**
       
    26 The CEZDecompressor class provides in-memory de-compression functions, including integrity checks of the compressed data.
       
    27 This version of the library supports only one compression / de-compression method (deflation / inflation).  De-compression
       
    28 can be done in a single step (using DecompressL()) if the buffers are large enough (for example if an input file is mmap'ed),
       
    29 or can be done by repeated calls of the InflateL() function.  The source data is de-compressed to the target buffer (both source 
       
    30 and target contained within the buffer manager argument).
       
    31 
       
    32 Note: In this version of the library a windowBits value of 8 is unsupported due to a problem with the window size being 
       
    33 set to 256 bytes. Although a value of 8 will be accepted by the CEZCompressor constructors, as it is being changed 
       
    34 internally by Zlib from 8 to 9, it will not be possible to use the same value for decompression. This is because the 
       
    35 Zlib functions called by the CEZDecompressor constructors do not make the same change internally and as a result a 
       
    36 KEZlibErrData is returned when calling InflateL(). It is therefore advised that for this version of the library 
       
    37 windowBits of 9 is used in place of 8.
       
    38 
       
    39 @publishedAll
       
    40 @released
       
    41 */
       
    42 class CEZDecompressor : public CEZZStream
       
    43 	{
       
    44 public:
       
    45 	/** Decompression panic values */
       
    46 	enum 
       
    47 		{
       
    48 		EInflateInitlialiserError = EUnexpected + 1,
       
    49 		EInflateVersionError,
       
    50 		EInflateTerminated,
       
    51 		EInflateDictionaryError
       
    52 		};
       
    53 		
       
    54 	/** Window Bits - the base two logarithm of the window size (the size of the history buffer) */
       
    55 	enum
       
    56 		{
       
    57 		EMaxWBits = MAX_WBITS
       
    58 		};
       
    59 
       
    60 public:
       
    61 	~CEZDecompressor();
       
    62 
       
    63 	IMPORT_C static CEZDecompressor* NewLC(MEZBufferManager& aInit, TInt aWindowBits = EMaxWBits);
       
    64 	IMPORT_C static CEZDecompressor* NewL(MEZBufferManager& aInit, TInt aWindowBits = EMaxWBits);
       
    65 
       
    66 	IMPORT_C static CEZDecompressor* NewLC(MEZBufferManager& aInit, const TDesC8& aDictionary, TInt aWindowBits = EMaxWBits);
       
    67 	IMPORT_C static CEZDecompressor* NewL(MEZBufferManager& aInit, const TDesC8& aDictionary, TInt aWindowBits = EMaxWBits);
       
    68 
       
    69 
       
    70 	IMPORT_C void ResetL(MEZBufferManager& aInit);
       
    71 	IMPORT_C TBool InflateL();
       
    72 
       
    73 	IMPORT_C static void DecompressL(TDes8 &aDestination, const TDesC8 &aSource);
       
    74 	
       
    75 	private:
       
    76 		enum TInflationState
       
    77 			{
       
    78 			ENoFlush,
       
    79 			EFinalize,
       
    80 			ETerminated
       
    81 			};
       
    82 
       
    83 	private:
       
    84 		void SetDictionaryL();
       
    85 		CEZDecompressor(MEZBufferManager* aInit);
       
    86 		CEZDecompressor(MEZBufferManager* aInit, const TUint8 *aDictionary, TInt aLength);
       
    87 		void ConstructL(TInt aWindowBits);
       
    88 
       
    89 	private:
       
    90 		MEZBufferManager* iBufferInit;
       
    91 		TInflationState iInflationState;
       
    92 		const TUint8* iDictionary;
       
    93 		TInt iDictionaryLength;
       
    94 	};
       
    95 
       
    96 #endif
       
    97 
       
    98