00001 00002 00003 00004 00005 00006 00007 00008 00009 #ifndef __STRING_TABLE_H 00010 #define __STRING_TABLE_H 00011 00012 #include "DS_OrderedList.h" 00013 #include "Export.h" 00014 #include "RakMemoryOverride.h" 00015 00017 namespace RakNet 00018 { 00019 class BitStream; 00020 }; 00021 00023 typedef unsigned char StringTableType; 00024 00026 struct StrAndBool 00027 { 00028 char *str; 00029 bool b; 00030 }; 00031 int RAK_DLL_EXPORT StrAndBoolComp( char *const &key, const StrAndBool &data ); 00032 00033 namespace RakNet 00034 { 00041 class RAK_DLL_EXPORT StringTable 00042 { 00043 public: 00044 00045 // Destructor 00046 ~StringTable(); 00047 00051 static StringTable* Instance(void); 00052 00056 void AddString(const char *str, bool copyString); 00057 00063 void EncodeString( const char *input, int maxCharsToWrite, RakNet::BitStream *output ); 00064 00070 bool DecodeString( char *output, int maxCharsToWrite, RakNet::BitStream *input ); 00071 00073 static void AddReference(void); 00074 00076 static void RemoveReference(void); 00077 00079 StringTable(); 00080 00081 protected: 00084 void LogStringNotFound(const char *strName); 00085 00087 static StringTable *instance; 00088 static int referenceCount; 00089 00090 DataStructures::OrderedList<char *, StrAndBool, StrAndBoolComp> orderedStringList; 00091 }; 00092 } 00093 00094 00095 #endif