#include <StringTable.h>
Public Member Functions | |
~StringTable () | |
Destructor. | |
void | AddString (const char *str, bool copyString) |
void | EncodeString (const char *input, int maxCharsToWrite, RakNet::BitStream *output) |
bool | DecodeString (char *output, int maxCharsToWrite, RakNet::BitStream *input) |
Static Public Member Functions | |
static StringTable * | Instance (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. | |
Protected Member Functions | |
void | LogStringNotFound (const char *strName) |
StringTable () | |
Private Constructor. | |
Protected Attributes | |
DataStructures::OrderedList< char *, StrAndBool, StrAndBoolComp > | orderedStringList |
Static Protected Attributes | |
static StringTable * | instance = 0 |
Singleton instance. | |
static int | referenceCount = 0 |
This is an even more efficient alternative to StringCompressor in that it writes a single byte from a lookup table and only does compression if the string does not already exist in the table. All string tables must match on all systems - hence you must add all the strings in the same order on all systems. Furthermore, this must be done before sending packets that use this class, since the strings are ordered for fast lookup. Adding after that time would mess up all the indices so don't do it. Don't use this class to write strings which were not previously registered with AddString, since you just waste bandwidth then. Use StringCompressor instead.
|
Add a string to the string table.
|
|
Writes input to output, uncompressed. Takes care of the null terminator for you. Relies on the StringCompressor class, which is automatically reference counted in the constructor and destructor in RakPeer. You can call the reference counting functions yourself if you wish too.
|
|
Writes input to output, compressed. Takes care of the null terminator for you. Relies on the StringCompressor class, which is automatically reference counted in the constructor and destructor in RakPeer. You can call the reference counting functions yourself if you wish too.
|
|
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.
|
|
Called when you mess up and send a string using this class that was not registered with AddString
|