Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

StringCompressor Class Reference

#include <StringCompressor.h>

List of all members.

Public Member Functions

 ~StringCompressor ()
void GenerateTreeFromStrings (unsigned char *input, unsigned inputLength)
void EncodeString (char *input, int maxCharsToWrite, RakNet::BitStream *output)
bool DecodeString (char *output, int maxCharsToWrite, RakNet::BitStream *input)

Static Public Member Functions

static StringCompressorInstance ()

Private Member Functions

void GenerateHuffmanEncodingTree (void)
 StringCompressor ()

Private Attributes

HuffmanEncodingTreehuffmanEncodingTree

Static Private Attributes

static StringCompressor instance


Detailed Description

This class provide compression for text in natural language. It is based on frequencies table and an Huffman encoding algorithm. This class follow the Singleton pattern. The default frequency table is for english language. You should generate your first frequencies table for the language in use in your application.


Constructor & Destructor Documentation

StringCompressor::~StringCompressor  ) 
 

Destructor

StringCompressor::StringCompressor  )  [private]
 

Default Constructor


Member Function Documentation

bool StringCompressor::DecodeString char *  output,
int  maxCharsToWrite,
RakNet::BitStream input
 

Writes input to output, uncompressed. Takes care of the null terminator for you. maxCharsToWrite should be the allocated size of output

Parameters:
[out] output a byte buffer previously allocated.
maxCharsToWrite The amount of byte available to store the result. There should be enought space in output to decode all the data
input The bitstream containing the data to process.

void StringCompressor::EncodeString char *  input,
int  maxCharsToWrite,
RakNet::BitStream output
 

Writes input to output, compressed. Takes care of the null terminator for you

Parameters:
input a byte buffer
maxCharsToWrite The size of input
output The bitstream that will contain the data of the compressed string

void StringCompressor::GenerateHuffmanEncodingTree void   )  [private]
 

Create Huffman frequencies Tree used for both encoding and decoding

void StringCompressor::GenerateTreeFromStrings unsigned char *  input,
unsigned  inputLength
 

Given an array of strings, such as a chat log, generate the optimal encoding tree for it. This function is optional and if it is not called a default tree will be used instead.

Parameters:
input An array of byte
inputLength The number of byte in the buffer

static StringCompressor* StringCompressor::Instance  )  [inline, static]
 

static function because only static functions can access static members Singleton pattern

Returns:
the unique instance of the StringCompressor
Todo:
Ensure there is no way to create a StringCompressor object


Member Data Documentation

HuffmanEncodingTree* StringCompressor::huffmanEncodingTree [private]
 

Huffman frequencies Tree

StringCompressor StringCompressor::instance [static, private]
 

Singleton instance


The documentation for this class was generated from the following files:
Generated on Mon May 30 17:45:43 2005 for raknet by  doxygen 1.4.2