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