Tramway SDK
uid.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_FRAMEWORK_UID_H
4#define TRAM_SDK_FRAMEWORK_UID_H
5
6#include <string>
7
8namespace tram {
9
10struct UID {
11 UID() {}
12 UID(const UID& value) { *this = value; }
13 ~UID() {}
14
15 UID(const std::string& value);
16 UID(const char* value);
17
18 UID& operator=(const UID& value) {
19 key = value.key;
20 return *this;
21 }
22
23 bool operator==(const UID& other) const {
24 return key == other.key;
25 }
26
27 bool operator==(const char* other) const {
28 return key == UID(other).key;
29 }
30
31 explicit operator bool() { return key; }
32
33 operator std::string() const;
34 operator char const*() const;
35
36 static bool no_quote(const char*);
37 static bool is_empty(const char*);
38 static bool is_valid(const UID&);
39
40 uint32_t key = 0;
41};
42
43typedef UID name_t;
44
45}
46
47#endif // TRAM_SDK_FRAMEWORK_UID_H
Serialization, i.e.
UID name_t
Definition: uid.h:43
Interned string type.
Definition: uid.h:10
bool operator==(const UID &other) const
Definition: uid.h:23
static bool no_quote(const char *)
Checks whether the name will need quotes.
Definition: uid.cpp:131
static bool is_empty(const char *)
Checks whether a string consists of only whitespace.
Definition: uid.cpp:144
bool operator==(const char *other) const
Definition: uid.h:27
~UID()
Definition: uid.h:13
UID(const UID &value)
Definition: uid.h:12
static bool is_valid(const UID &)
Checks whether the name is valid.
Definition: uid.cpp:121
uint32_t key
Definition: uid.h:40
UID()
Definition: uid.h:11
UID & operator=(const UID &value)
Definition: uid.h:18