![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
Writes and reads strings to and from bitstreams. More...
#include <StringCompressor.h>
Public Member Functions | |
| bool | DecodeString (char *output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0) |
| bool | DecodeString (RakNet::RakString *output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0) |
| void | EncodeString (const char *input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0) |
| void | EncodeString (const RakNet::RakString *input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0) |
| void | GenerateTreeFromStrings (unsigned char *input, unsigned inputLength, uint8_t languageId) |
| StringCompressor () | |
| ~StringCompressor () | |
Static Public Member Functions | |
| static void | AddReference (void) |
| Used so I can allocate and deallocate this singleton at runtime. | |
| static StringCompressor * | Instance (void) |
| static void | RemoveReference (void) |
| Used so I can allocate and deallocate this singleton at runtime. | |
Private Attributes | |
| DataStructures::Map< int, HuffmanEncodingTree * > | huffmanEncodingTrees |
| Pointer to the huffman encoding trees. | |
Static Private Attributes | |
| static StringCompressor * | instance |
| Singleton instance. | |
| static int | referenceCount |
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 38 of file StringCompressor.h.
| RakNet::StringCompressor::~StringCompressor | ( | ) |
| RakNet::StringCompressor::StringCompressor | ( | ) |
| static void RakNet::StringCompressor::AddReference | ( | void | ) | [static] |
| bool RakNet::StringCompressor::DecodeString | ( | char * | output, |
| int | maxCharsToWrite, | ||
| RakNet::BitStream * | input, | ||
| uint8_t | languageId = 0 |
||
| ) |
Writes input to output, uncompressed. Takes care of the null terminator for you.
| [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 |
| bool RakNet::StringCompressor::DecodeString | ( | RakNet::RakString * | output, |
| int | maxCharsToWrite, | ||
| RakNet::BitStream * | input, | ||
| uint8_t | languageId = 0 |
||
| ) |
| void RakNet::StringCompressor::EncodeString | ( | const char * | input, |
| int | maxCharsToWrite, | ||
| RakNet::BitStream * | output, | ||
| uint8_t | languageId = 0 |
||
| ) |
Writes input to output, compressed. Takes care of the null terminator for you.
| [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 |
| void RakNet::StringCompressor::EncodeString | ( | const RakNet::RakString * | input, |
| int | maxCharsToWrite, | ||
| RakNet::BitStream * | output, | ||
| uint8_t | languageId = 0 |
||
| ) |
| void RakNet::StringCompressor::GenerateTreeFromStrings | ( | unsigned char * | input, |
| unsigned | inputLength, | ||
| uint8_t | 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.
| [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. |
| static StringCompressor* RakNet::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.
Referenced by SraNetwork::Helpers::GetStringFromBuffer(), and SraNetwork::Helpers::StoreStringInBuffer().
| static void RakNet::StringCompressor::RemoveReference | ( | void | ) | [static] |
DataStructures::Map<int, HuffmanEncodingTree *> RakNet::StringCompressor::huffmanEncodingTrees [private] |
Definition at line 98 of file StringCompressor.h.
StringCompressor* RakNet::StringCompressor::instance [static, private] |
Definition at line 95 of file StringCompressor.h.
int RakNet::StringCompressor::referenceCount [static, private] |
Definition at line 100 of file StringCompressor.h.
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.