TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BinaryFormat.h
Go to the documentation of this file.
1 
12 #ifndef G3D_BINARYFORMAT_H
13 #define G3D_BINARYFORMAT_H
14 
15 #include "G3D/platform.h"
16 #include "G3D/g3dmath.h"
17 
18 namespace G3D {
19 
20 class Vector2;
21 class Vector2int16;
22 class Vector3;
23 class Vector3int16;
24 class Vector4;
25 class Vector4int16;
26 class Color3;
27 class Color3uint8;
28 class Color4;
29 class Color4uint8;
30 
37 // Must be packed int 16 bits for the chunk reader
38 // We can't name these just "INT8" etc. because some libraries #define names like that
40  FIRST_BINFMT = 1000,
41 
51 
53 
55 
57 };
58 
59 }
60 
64 // This implementation is designed to meet the following constraints:
65 // 1. Work around the many MSVC++ partial template bugs
66 // 2. Work for primitive types (e.g. int)
67 #define binaryFormatOf(T) (G3D::_internal::_BinaryFormat<T>::x())
68 
69 namespace G3D {
70 namespace _internal {
71 
72 
73 template<class T> class _BinaryFormat {
74 public:
75  static BinaryFormat x() {
76  return CUSTOM_BINFMT;
77  }
78 };
79 }}
80 
81 
93 #define DECLARE_BINARYFORMATOF(CType, EnumType) \
94 namespace G3D { \
95  namespace _internal { \
96  template<> class _BinaryFormat<CType> { \
97  public: \
98  static BinaryFormat x() { \
99  return EnumType; \
100  } \
101  }; \
102  } \
103 }
104 
106 
115 
118 
125 
130 
131 namespace G3D {
132 
135 int32 byteSize(BinaryFormat f);
136 
137 
138 } //G3D
139 
140 #endif
BinaryFormat
Definition: BinaryFormat.h:39
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:43
int8_t int8
Definition: Define.h:148
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:43
int64_t int64
Definition: Define.h:145
Definition: BinaryFormat.h:48
static BinaryFormat x()
Definition: BinaryFormat.h:75
Definition: BinaryFormat.h:47
Definition: BinaryFormat.h:47
double float64
Definition: g3dmath.h:173
Definition: BinaryFormat.h:44
Definition: AABox.h:25
Definition: BinaryFormat.h:48
Definition: BinaryFormat.h:50
Definition: BinaryFormat.h:50
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:46
Definition: BinaryFormat.h:44
Definition: BinaryFormat.h:44
Definition: BinaryFormat.h:73
Definition: BinaryFormat.h:48
float float32
Definition: g3dmath.h:172
Definition: BinaryFormat.h:43
int32_t int32
Definition: Define.h:146
Definition: BinaryFormat.h:50
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
uint16_t uint16
Definition: Define.h:151
Definition: BinaryFormat.h:40
Definition: BinaryFormat.h:50
#define DECLARE_BINARYFORMATOF(CType, EnumType)
Definition: BinaryFormat.h:93
Definition: BinaryFormat.h:46
Definition: BinaryFormat.h:49
Definition: BinaryFormat.h:45
Definition: BinaryFormat.h:56
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:54
uint8_t uint8
Definition: Define.h:152
Definition: BinaryFormat.h:49
Definition: BinaryFormat.h:43
int16_t int16
Definition: Define.h:147
int32 byteSize(BinaryFormat f)
Definition: BinaryFormat.cpp:13
Definition: BinaryFormat.h:45
Definition: BinaryFormat.h:50
Definition: BinaryFormat.h:49
Definition: BinaryFormat.h:52
Definition: Vector2int16.h:22
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:43
Definition: BinaryFormat.h:42