SLikeNet  0.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringTable.h
Go to the documentation of this file.
1 /*
2  * Original work: Copyright (c) 2014, Oculus VR, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7  * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8  *
9  *
10  * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11  *
12  * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13  * license found in the license.txt file in the root directory of this source tree.
14  */
15 
19 
20 
21 
22 #ifndef __STRING_TABLE_H
23 #define __STRING_TABLE_H
24 
25 #include "DS_OrderedList.h"
26 #include "Export.h"
27 #include "memoryoverride.h"
28 
30 namespace SLNet
31 {
32  class BitStream;
33 };
34 
36 typedef unsigned char StringTableType;
37 
39 struct StrAndBool
40 {
41  char *str;
42  bool b;
43 };
44 
45 namespace SLNet
46 {
47  int RAK_DLL_EXPORT StrAndBoolComp( char *const &key, const StrAndBool &data );
48 
56  {
57  public:
58 
59  // Destructor
60  ~StringTable();
61 
65  static StringTable* Instance(void);
66 
70  void AddString(const char *str, bool copyString);
71 
77  void EncodeString( const char *input, int maxCharsToWrite, SLNet::BitStream *output );
78 
84  bool DecodeString( char *output, int maxCharsToWrite, SLNet::BitStream *input );
85 
87  static void AddReference(void);
88 
90  static void RemoveReference(void);
91 
93  StringTable();
94 
95  protected:
98  void LogStringNotFound(const char *strName);
99 
102  static int referenceCount;
103 
105  };
106 }
107 
108 
109 #endif