Shadowrun: Awakened 29 September 2011 - Build 871
StringCompressor.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef __STRING_COMPRESSOR_H
00010 #define __STRING_COMPRESSOR_H
00011 
00012 #include "Export.h"
00013 #include "DS_Map.h"
00014 #include "RakMemoryOverride.h"
00015 #include "NativeTypes.h"
00016 
00017 #ifdef _STD_STRING_COMPRESSOR
00018 #include <string>
00019 #endif
00020 
00022 namespace RakNet
00023 {
00024     class BitStream;
00025     class RakString;
00026 };
00027 
00028 
00029 namespace RakNet
00030 {
00032 class HuffmanEncodingTree;
00033 
00038 class RAK_DLL_EXPORT StringCompressor
00039 {
00040 public:
00041     
00042     // Destructor   
00043     ~StringCompressor();
00044     
00048     static StringCompressor* Instance(void);
00049 
00055     void GenerateTreeFromStrings( unsigned char *input, unsigned inputLength, uint8_t languageId );
00056     
00062     void EncodeString( const char *input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0 );
00063     
00069     bool DecodeString( char *output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0 );
00070 
00071 #ifdef _CSTRING_COMPRESSOR
00072     void EncodeString( const CString &input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0 );
00073     bool DecodeString( CString &output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0 );
00074 #endif
00075 
00076 #ifdef _STD_STRING_COMPRESSOR
00077     void EncodeString( const std::string &input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0 );
00078     bool DecodeString( std::string *output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0 );
00079 #endif
00080 
00081     void EncodeString( const RakNet::RakString *input, int maxCharsToWrite, RakNet::BitStream *output, uint8_t languageId=0 );
00082     bool DecodeString( RakNet::RakString *output, int maxCharsToWrite, RakNet::BitStream *input, uint8_t languageId=0 );
00083 
00085     static void AddReference(void);
00086     
00088     static void RemoveReference(void);
00089 
00090     StringCompressor();
00091 
00092 private:
00093     
00095     static StringCompressor *instance;
00096     
00098     DataStructures::Map<int, HuffmanEncodingTree *> huffmanEncodingTrees;
00099     
00100     static int referenceCount;
00101 };
00102 
00103 } // namespace RakNet
00104 
00105 #endif

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