Public Member Functions | Static Public Member Functions

StringCompressor Class Reference

Writes and reads strings to and from bitstreams. More...

#include <StringCompressor.h>

Collaboration diagram for StringCompressor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~StringCompressor ()
void GenerateTreeFromStrings (unsigned char *input, unsigned inputLength, int languageID)
void EncodeString (const char *input, int maxCharsToWrite, RakNet::BitStream *output, int languageID=0)
bool DecodeString (char *output, int maxCharsToWrite, RakNet::BitStream *input, int languageID=0)
void EncodeString (const RakNet::RakString *input, int maxCharsToWrite, RakNet::BitStream *output, int languageID=0)
bool DecodeString (RakNet::RakString *output, int maxCharsToWrite, RakNet::BitStream *input, int languageID=0)
 StringCompressor ()
 Private Constructor.

Static Public Member Functions

static StringCompressorInstance (void)
static void AddReference (void)
 Used so I can allocate and deallocate this singleton at runtime.
static void RemoveReference (void)
 Used so I can allocate and deallocate this singleton at runtime.

Detailed Description

Writes and reads strings to and from bitstreams.

Only works with ASCII strings. The default compression is for English. You can call GenerateTreeFromStrings to compress and decompress other languages efficiently as well.

Definition at line 32 of file StringCompressor.h.


Constructor & Destructor Documentation

StringCompressor::~StringCompressor (  ) 

Definition at line 350 of file StringCompressor.cpp.

Here is the call graph for this function:

StringCompressor::StringCompressor (  ) 

Private Constructor.

Definition at line 312 of file StringCompressor.cpp.

Here is the call graph for this function:


Member Function Documentation

void StringCompressor::AddReference ( void   )  [static]

Used so I can allocate and deallocate this singleton at runtime.

Definition at line 26 of file StringCompressor.cpp.

Here is the caller graph for this function:

bool StringCompressor::DecodeString ( char *  output,
int  maxCharsToWrite,
RakNet::BitStream input,
int  languageID = 0 
)

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

Parameters:
[out] output A block of bytes to receive the output
[in] maxCharsToWrite Size, in bytes, of output . A NULL terminator will always be appended to the output string. If the maxCharsToWrite is not large enough, the string will be truncated.
[in] input The bitstream containing the compressed string
[in] languageID Which language to use

Definition at line 389 of file StringCompressor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool StringCompressor::DecodeString ( RakNet::RakString output,
int  maxCharsToWrite,
RakNet::BitStream input,
int  languageID = 0 
)

Definition at line 471 of file StringCompressor.cpp.

Here is the call graph for this function:

void StringCompressor::EncodeString ( const char *  input,
int  maxCharsToWrite,
RakNet::BitStream output,
int  languageID = 0 
)

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

Parameters:
[in] input Pointer to an ASCII string
[in] maxCharsToWrite The max number of bytes to write of input. Use 0 to mean no limit.
[out] output The bitstream to write the compressed string to
[in] languageID Which language to use

Definition at line 356 of file StringCompressor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void StringCompressor::EncodeString ( const RakNet::RakString input,
int  maxCharsToWrite,
RakNet::BitStream output,
int  languageID = 0 
)

Definition at line 467 of file StringCompressor.cpp.

Here is the call graph for this function:

void StringCompressor::GenerateTreeFromStrings ( unsigned char *  input,
unsigned  inputLength,
int  languageID 
)

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:
[in] input An array of bytes which should point to text.
[in] inputLength Length of input
[in] languageID An identifier for the language / string table to generate the tree for. English is automatically created with ID 0 in the constructor.

Definition at line 322 of file StringCompressor.cpp.

Here is the call graph for this function:

StringCompressor * StringCompressor::Instance ( void   )  [static]

static function because only static functions can access static members The RakPeer constructor adds a reference to this class, so don't call this until an instance of RakPeer exists, or unless you call AddReference yourself.

Returns:
the unique instance of the StringCompressor

Definition at line 47 of file StringCompressor.cpp.

void StringCompressor::RemoveReference ( void   )  [static]

Used so I can allocate and deallocate this singleton at runtime.

Definition at line 33 of file StringCompressor.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: