TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUniqueID.h
Go to the documentation of this file.
1 
5 #ifndef G3D_GUniqueID_h
6 #define G3D_GUniqueID_h
7 
8 #include "G3D/platform.h"
9 #include "G3D/g3dmath.h"
10 #include "G3D/Table.h"
11 
12 namespace G3D {
13 
14 class Any;
15 
23 class GUniqueID {
24 private:
25 
27 
28 public:
29 
31  GUniqueID() : id(0) {}
32 
33  GUniqueID& operator=(const Any& a);
34 
36  GUniqueID(const Any& a) {
37  *this = a;
38  }
39 
40  Any toAny() const;
41 
43  std::string toString16() const;
44 
45  static GUniqueID fromString16(const std::string& s);
46 
49  static GUniqueID NONE(uint16 tag);
50 
51  bool uninitialized() const {
52  return id == 0;
53  }
54 
55  uint16 tag() const {
56  return id >> 54;
57  }
58 
59  operator uint64() const {
60  return id;
61  }
62 
63  bool operator==(const GUniqueID& other) const {
64  return id == other.id;
65  }
66 
67  bool operator!=(const GUniqueID& other) const {
68  return id != other.id;
69  }
70 
71  void serialize(class BinaryOutput& b) const;
72 
73  void deserialize(class BinaryInput& b);
74 
75  void serialize(class TextOutput& t) const;
76 
77  void deserialize(class TextInput& t);
78 
80  static GUniqueID create(uint16 tag = 0);
81 };
82 
83 } // G3D
84 
86 template<> struct HashTrait<class G3D::GUniqueID> {
87  static size_t hashCode(G3D::GUniqueID id) { return (size_t)(G3D::uint64)id; }
88 };
89 
90 #endif
GUniqueID(const Any &a)
Definition: GUniqueID.h:36
Definition: BinaryInput.h:69
uint64 id
Definition: GUniqueID.h:26
static GUniqueID create(uint16 tag=0)
Definition: GUniqueID.cpp:83
Definition: HashTrait.h:105
GUniqueID()
Definition: GUniqueID.h:31
Definition: AABox.h:25
uint64_t uint64
Definition: g3dmath.h:170
Any toAny() const
Definition: GUniqueID.cpp:26
void deserialize(class BinaryInput &b)
Definition: GUniqueID.cpp:38
uint16_t uint16
Definition: g3dmath.h:166
std::string toString16() const
Definition: GUniqueID.cpp:64
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
static GUniqueID NONE(uint16 tag)
Definition: GUniqueID.cpp:56
static size_t hashCode(G3D::GUniqueID id)
Definition: GUniqueID.h:87
GUniqueID & operator=(const Any &a)
Definition: GUniqueID.cpp:15
A simple tokenizer for parsing text files.
Definition: TextInput.h:223
Definition: TextOutput.h:60
Definition: GUniqueID.h:23
bool operator==(const GUniqueID &other) const
Definition: GUniqueID.h:63
Definition: BinaryOutput.h:52
bool operator!=(const GUniqueID &other) const
Definition: GUniqueID.h:67
static GUniqueID fromString16(const std::string &s)
Definition: GUniqueID.cpp:69
uint16 tag() const
Definition: GUniqueID.h:55
void serialize(class BinaryOutput &b) const
Definition: GUniqueID.cpp:33
bool uninitialized() const
Definition: GUniqueID.h:51