persistentstorage/store/INC/S32HUF.H
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-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 //
       
    15 
       
    16 #if !defined(__S32HUF_H__)
       
    17 #define __S32HUF_H__
       
    18 #if !defined(__S32BUF_H__)
       
    19 #include <s32buf.h>
       
    20 #endif
       
    21 #if !defined(__S32STRM_H__)
       
    22 #include <s32strm.h>
       
    23 #endif
       
    24 
       
    25 class Huffman // Huffman primitives: sell to base
       
    26 	{
       
    27 public:
       
    28 	IMPORT_C static const TUint* DefaultBits(); // long code needs to be sorted out
       
    29 	IMPORT_C static const TUint8* DefaultTree(); // is there a real case for default tables?
       
    30 //
       
    31 	IMPORT_C void Encode(...); // incremental encoding and decoding primitives
       
    32 	IMPORT_C void Decode(...); // suitable for sharing between descriptors and filters
       
    33 	};
       
    34 //
       
    35 class THufEncodeFilter : public TStreamFilter
       
    36 	{
       
    37 public:
       
    38 	IMPORT_C THufEncodeFilter();
       
    39 	IMPORT_C void Set(MStreamBuf* aHost,const TUint* aHufBits,TInt aMode=EWrite);
       
    40 protected:
       
    41 	IMPORT_C TInt Capacity(TInt aMaxLength);
       
    42 	IMPORT_C TInt FilterL(TAny* aPtr,TInt aMaxLength,const TUint8*& aFrom,const TUint8* anEnd);
       
    43 	IMPORT_C void DoSynchL();
       
    44 private:
       
    45 	const TUint* iTable;
       
    46 	TInt iMaxBits;
       
    47 	TUint iOut;
       
    48 	TInt iBit;
       
    49 	};
       
    50 class THufDecodeFilter : public TStreamFilter
       
    51 	{
       
    52 public:
       
    53 	IMPORT_C THufDecodeFilter();
       
    54 	IMPORT_C void Set(MStreamBuf* aHost,const TUint8* aHufTree,TInt aMode=ERead);
       
    55 protected:
       
    56 	IMPORT_C TInt Capacity(TInt aMaxLength);
       
    57 	IMPORT_C TInt FilterL(TAny* aPtr,TInt aMaxLength,const TUint8*& aFrom,const TUint8* anEnd);
       
    58 	IMPORT_C void DoSynchL();
       
    59 private:
       
    60 	const TUint8* iRoot;
       
    61 	const TUint8* iNode;
       
    62 	TUint iBits;
       
    63 	};
       
    64 //
       
    65 class RHufDecodeReadStream : public RReadStream
       
    66 	{
       
    67 public:
       
    68 	RHufDecodeReadStream() {}
       
    69 	IMPORT_C RHufDecodeReadStream(RReadStream& aHost,const TUint8* aHufTree=Huffman::DefaultTree());
       
    70 	IMPORT_C void Open(RReadStream& aHost,const TUint8* aHufTree=Huffman::DefaultTree());
       
    71 private:
       
    72 	THufDecodeFilter iFilter;
       
    73 	};
       
    74 class RHufEncodeWriteStream : public RWriteStream
       
    75 	{
       
    76 public:
       
    77 	RHufEncodeWriteStream() {}
       
    78 	inline RHufEncodeWriteStream(const MExternalizer<TStreamRef>& anExter);
       
    79 	IMPORT_C RHufEncodeWriteStream(RWriteStream& aHost,const TUint* aHufBits=Huffman::DefaultBits());
       
    80 	IMPORT_C void Open(RWriteStream& aHost,const TUint* aHufBits=Huffman::DefaultBits());
       
    81 private:
       
    82 	THufEncodeFilter iFilter;
       
    83 	};
       
    84 //
       
    85 class RHufEncodeReadStream : public RReadStream
       
    86 	{
       
    87 public:
       
    88 	RHufEncodeReadStream() {}
       
    89 	IMPORT_C RHufEncodeReadStream(RReadStream& aHost,const TUint* aHufBits=Huffman::DefaultBits());
       
    90 	IMPORT_C void Open(RReadStream& aHost,const TUint* aHufBits=Huffman::DefaultBits());
       
    91 private:
       
    92 	THufEncodeFilter iFilter;
       
    93 	};
       
    94 class RHufDecodeWriteStream : public RWriteStream
       
    95 	{
       
    96 public:
       
    97 	RHufDecodeWriteStream() {}
       
    98 	inline RHufDecodeWriteStream(const MExternalizer<TStreamRef>& anExter);
       
    99 	IMPORT_C RHufDecodeWriteStream(RWriteStream& aHost,const TUint8* aHufTree=Huffman::DefaultTree());
       
   100 	IMPORT_C void Open(RWriteStream& aHost,const TUint8* aHufTree=Huffman::DefaultTree());
       
   101 private:
       
   102 	THufDecodeFilter iFilter;
       
   103 	};
       
   104 
       
   105 #include "S32HUF.INL"
       
   106 #endif