Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
RakNet::StringTable Class Reference

Writes a string index, instead of the whole string. More...

#include <StringTable.h>

List of all members.

Public Member Functions

void AddString (const char *str, bool copyString)
bool DecodeString (char *output, int maxCharsToWrite, RakNet::BitStream *input)
void EncodeString (const char *input, int maxCharsToWrite, RakNet::BitStream *output)
 StringTable ()
 Private Constructor.
 ~StringTable ()

Static Public Member Functions

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

Protected Member Functions

void LogStringNotFound (const char *strName)

Protected Attributes

DataStructures::OrderedList
< char *, StrAndBool,
StrAndBoolComp > 
orderedStringList

Static Protected Attributes

static StringTableinstance
 Singleton instance.
static int referenceCount

Detailed Description

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.

Definition at line 42 of file StringTable.h.


Constructor & Destructor Documentation

RakNet::StringTable::~StringTable ( )
RakNet::StringTable::StringTable ( )

Member Function Documentation

static void RakNet::StringTable::AddReference ( void  ) [static]
void RakNet::StringTable::AddString ( const char *  str,
bool  copyString 
)

Add a string to the string table.

Parameters:
[in]strThe string to add to the string table
[in]copyStringtrue to make a copy of the passed string (takes more memory), false to not do so (if your string is in static memory).
bool RakNet::StringTable::DecodeString ( char *  output,
int  maxCharsToWrite,
RakNet::BitStream input 
)

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.

Parameters:
[out]outputA block of bytes to receive the output
[in]maxCharsToWriteSize, 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]inputThe bitstream containing the compressed string
void RakNet::StringTable::EncodeString ( const char *  input,
int  maxCharsToWrite,
RakNet::BitStream output 
)

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.

Parameters:
[in]inputPointer to an ASCII string
[in]maxCharsToWriteThe size of input
[out]outputThe bitstream to write the compressed string to
static StringTable* RakNet::StringTable::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 StringTable
void RakNet::StringTable::LogStringNotFound ( const char *  strName) [protected]

Called when you mess up and send a string using this class that was not registered with AddString

Parameters:
[in]maxCharsToWriteSize, 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.
static void RakNet::StringTable::RemoveReference ( void  ) [static]

Member Data Documentation

Definition at line 88 of file StringTable.h.

Definition at line 91 of file StringTable.h.

int RakNet::StringTable::referenceCount [static, protected]

Definition at line 89 of file StringTable.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net