"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

lsc::CLzwDecodingDict Class Reference

A dictionary for decoding an LZW bytestream. More...

#include <LSCLzwDecodingDict.h>

List of all members.

Classes

struct  LSN_LZW_DICT_ENTRY

Public Types

typedef LSUINT32 LSN_LZW_CODE
typedef struct
lsc::CLzwDecodingDict::LSN_LZW_DICT_ENTRY
LPLSN_LZW_DICT_ENTRY
typedef struct
lsc::CLzwDecodingDict::LSN_LZW_DICT_ENTRY 
LPCLSN_LZW_DICT_ENTRY

Public Member Functions

LSVOID LSE_CALL Reset ()
LSVOID LSE_CALL SetAllocator (CStdAllocator *_psaAllocator)
LSVOID LSE_CALL InitializeDictionary (LSUINT32 _ui32Len, LSUINT32 _ui32MaxBits)
LSBOOL LSE_CALL IsClearCode (LSN_LZW_CODE _lcCode) const
LSBOOL LSE_CALL IsEndOfInputCode (LSN_LZW_CODE _lcCode) const
LSUINT32 LSE_CALL GetTotal () const
LSBOOL LSE_CALL AddCode (LSN_LZW_CODE _lcCode, LSUINT8 _ui8Char)
LSBOOL LSE_CALL GetString (LSN_LZW_CODE _lcCode, CString &_sString) const
LSE_INLINE LSUINT32 LSE_CALL GetBitsNeeded () const

Protected Member Functions

LSBOOL LSE_CALL Alloc ()
LSUINT32 LSE_CALL DeriveBitsNeeded () const

Protected Attributes

CAllocator m_aAllocator
LPLSN_LZW_DICT_ENTRY m_lpldeDictionary
LSUINT32 m_ui32Total
LSUINT32 m_ui32Alloc
LSUINT32 m_ui32RootLen
LSUINT32 m_ui32MaxSize
LSUINT32 m_ui32MaxBits
LSUINT32 m_ui32BitsNeeded

Detailed Description

A dictionary for decoding an LZW bytestream.

Class CLzwDecodingDict Description: When decoding, the dictionary format for dictionary entries in the LZW compression scheme are different from when encoding. The codes are referenced only by code during decompression, allowing us to store the entries linearly during decompression. Our loop-up and usage functiosn for the codes are different from the ones used during encryption.


Member Typedef Documentation

A dictionary entry. The code of the item is its index in the array.

A code.


Member Function Documentation

LSBOOL LSE_CALL lsc::CLzwDecodingDict::AddCode ( LSN_LZW_CODE  _lcCode,
LSUINT8  _ui8Char 
)

Add a code to the dictionary. Fails if the dictionary is full.

Parameters:
_lcCodeThe code to be added.
_ui8CharThe character associated with this code.
LSBOOL LSE_CALL lsc::CLzwDecodingDict::Alloc ( ) [protected]

Allocate the full set of codes and initialize the roots.

Returns:
Returns false if allocation fails or if m_ui32RootLen is 0.
LSUINT32 LSE_CALL lsc::CLzwDecodingDict::DeriveBitsNeeded ( ) const [protected]

Derive the total number of bits needed to read any code in the dictionary.

Returns:
Returns the number of bits needed for a code in the stream given the current size of the dictionary.
LSE_INLINE LSUINT32 LSE_CALL lsc::CLzwDecodingDict::GetBitsNeeded ( ) const

Get the number of bits needed to access any code.

Returns:
Returns the minimum number of bits needed to access any code in the dictionary.
LSBOOL LSE_CALL lsc::CLzwDecodingDict::GetString ( LSN_LZW_CODE  _lcCode,
CString &  _sString 
) const

Get a string from the dictionary. Translates all codes to characters and returns the length of the string. The string is returned in reverse order.

Parameters:
_lcCodeThe code to translate into a byte string.
_sStringUpone return, this string contains the returned bytes.
Returns:
Returns true if the string was extracted successfully. If any unknown codes are encountered, false is returned.
LSUINT32 LSE_CALL lsc::CLzwDecodingDict::GetTotal ( ) const

Get the size of the dictionary.

Returns:
Returns the number of codes in the dictionary.
LSVOID LSE_CALL lsc::CLzwDecodingDict::InitializeDictionary ( LSUINT32  _ui32Len,
LSUINT32  _ui32MaxBits 
)

Set the initial dictionary where each entry is a root.

Parameters:
_ui32LenNumber of root entries in the dictionary.
_ui32MaxBitsMaximum number of bits in any entry in the dictionary.
LSBOOL LSE_CALL lsc::CLzwDecodingDict::IsClearCode ( LSN_LZW_CODE  _lcCode) const

Is the given code the clear code?

Parameters:
_lcCodeThe code to be tested against the clear code.
Returns:
Returns true if the code is the clear code.
LSBOOL LSE_CALL lsc::CLzwDecodingDict::IsEndOfInputCode ( LSN_LZW_CODE  _lcCode) const

Is the given code the end-of-input code?

Parameters:
_lcCodeThe code to be tested against the end-of-input code.
Returns:
Returns true if the code is the end-of-input code.
LSVOID LSE_CALL lsc::CLzwDecodingDict::Reset ( )

Reset everything. Deallocates all resources.

LSVOID LSE_CALL lsc::CLzwDecodingDict::SetAllocator ( CStdAllocator *  _psaAllocator)

Set the allocator. If different from the current allocator, the dictionary is reset.

Parameters:
_psaAllocatorThe allocator to use by this class.

Member Data Documentation

CAllocator lsc::CLzwDecodingDict::m_aAllocator [protected]

Our allocator.

The dictionary.

The bits needed for the current code.

Maximum number of bits in an entry.

Maximum size.

Size of the root.

LSUINT32 lsc::CLzwDecodingDict::m_ui32Total [protected]

The size of the dictionary.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator