williamr@2: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // Declaration for Decompression class williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __EZDECOMPRESSOR_H__ williamr@2: #define __EZDECOMPRESSOR_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: /** williamr@2: The CEZDecompressor class provides in-memory de-compression functions, including integrity checks of the compressed data. williamr@2: This version of the library supports only one compression / de-compression method (deflation / inflation). De-compression williamr@2: can be done in a single step (using DecompressL()) if the buffers are large enough (for example if an input file is mmap'ed), williamr@2: or can be done by repeated calls of the InflateL() function. The source data is de-compressed to the target buffer (both source williamr@2: and target contained within the buffer manager argument). williamr@2: williamr@4: Note: In this version of the library a windowBits value of 8 is unsupported due to a problem with the window size being williamr@4: set to 256 bytes. Although a value of 8 will be accepted by the CEZCompressor constructors, as it is being changed williamr@4: internally by Zlib from 8 to 9, it will not be possible to use the same value for decompression. This is because the williamr@4: Zlib functions called by the CEZDecompressor constructors do not make the same change internally and as a result a williamr@4: KEZlibErrData is returned when calling InflateL(). It is therefore advised that for this version of the library williamr@4: windowBits of 9 is used in place of 8. williamr@4: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CEZDecompressor : public CEZZStream williamr@2: { williamr@2: public: williamr@2: /** Decompression panic values */ williamr@2: enum williamr@2: { williamr@2: EInflateInitlialiserError = EUnexpected + 1, williamr@2: EInflateVersionError, williamr@2: EInflateTerminated, williamr@2: EInflateDictionaryError williamr@2: }; williamr@2: williamr@2: /** Window Bits - the base two logarithm of the window size (the size of the history buffer) */ williamr@2: enum williamr@2: { williamr@2: EMaxWBits = MAX_WBITS williamr@2: }; williamr@2: williamr@2: public: williamr@2: ~CEZDecompressor(); williamr@2: williamr@2: IMPORT_C static CEZDecompressor* NewLC(MEZBufferManager& aInit, TInt aWindowBits = EMaxWBits); williamr@2: IMPORT_C static CEZDecompressor* NewL(MEZBufferManager& aInit, TInt aWindowBits = EMaxWBits); williamr@2: williamr@2: IMPORT_C static CEZDecompressor* NewLC(MEZBufferManager& aInit, const TDesC8& aDictionary, TInt aWindowBits = EMaxWBits); williamr@2: IMPORT_C static CEZDecompressor* NewL(MEZBufferManager& aInit, const TDesC8& aDictionary, TInt aWindowBits = EMaxWBits); williamr@2: williamr@2: williamr@2: IMPORT_C void ResetL(MEZBufferManager& aInit); williamr@2: IMPORT_C TBool InflateL(); williamr@2: williamr@2: IMPORT_C static void DecompressL(TDes8 &aDestination, const TDesC8 &aSource); williamr@4: williamr@2: private: williamr@2: enum TInflationState williamr@2: { williamr@2: ENoFlush, williamr@2: EFinalize, williamr@2: ETerminated williamr@2: }; williamr@2: williamr@2: private: williamr@2: void SetDictionaryL(); williamr@2: CEZDecompressor(MEZBufferManager* aInit); williamr@2: CEZDecompressor(MEZBufferManager* aInit, const TUint8 *aDictionary, TInt aLength); williamr@2: void ConstructL(TInt aWindowBits); williamr@2: williamr@2: private: williamr@2: MEZBufferManager* iBufferInit; williamr@2: TInflationState iInflationState; williamr@2: const TUint8* iDictionary; williamr@2: TInt iDictionaryLength; williamr@2: }; williamr@2: williamr@2: #endif williamr@4: williamr@4: