-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEnum.h
60 lines (42 loc) · 1.16 KB
/
Enum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef __ENUM_H__
#define __ENUM_H__
#include <string>
#include <vector>
#include <map>
#include <stdint.h>
#include "RefCountObject.h"
struct EnumMember
{
std::string name;
uint32_t value;
bool isDefault;
};
struct OutputBlock;
struct InputBlock;
class Struct;
struct DuplicateContext;
class Enum: public RefCountObject
{
std::string m_name;
std::vector<EnumMember> m_members;
uint32_t m_nextValue;
bool m_fullyDefined;
size_t m_serializationIndex;
bool m_serializationIndexValid;
static size_t m_nextSerializationIndex;
static std::map< size_t, Ref<Enum> > m_serializationMap;
public:
Enum();
Enum* Duplicate(DuplicateContext& dup);
void ReplaceWith(Enum* e);
bool IsFullyDefined() const { return m_fullyDefined; }
void Complete() { m_fullyDefined = true; }
void SetName(const std::string& name) { m_name = name; }
const std::string& GetName() const { return m_name; }
const std::vector<EnumMember>& GetMembers() const { return m_members; }
uint32_t GetNextValue() const { return m_nextValue; }
void AddMember(const std::string& name, uint32_t value);
void Serialize(OutputBlock* output);
static Enum* Deserialize(InputBlock* input);
};
#endif