-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbobject.pat
85 lines (76 loc) · 2.21 KB
/
dbobject.pat
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <type/leb128.pat>
#include <fb/guid.pat>
#include <fb/sha1.pat>
namespace fb
{
namespace DbObject
{
enum Type : u8
{
NULL = 0,
Array = 1,
Object = 2,
Boolean = 6,
String = 7,
Int = 8,
Long = 9,
Single = 11,
Double = 12,
Guid = 15,
Sha1 = 16,
ByteArray = 19
};
bitfield Flags
{
Type type : 5;
unk : 2;
bool anonymous : 1;
};
struct DbObjectElement
{
Flags flags [[hidden]];
if (flags.type != Type::NULL && !flags.anonymous)
{
char name[] [[hidden]];
}
else
{
str name = "{}";
}
match (flags.type)
{
(Type::Array):
{
type::uLEB128 size [[hidden]];
DbObjectElement value[while($ < addressof(size) + sizeof(size) + size)] [[name(name)]];
}
(Type::Object):
{
type::uLEB128 size [[hidden]];
DbObjectElement value[while($ < addressof(size) + sizeof(size) + size)] [[name(name)]];
}
(Type::Boolean): bool value [[name(name)]];
(Type::String):
{
type::uLEB128 size [[hidden]];
char value[size] [[name(name)]];
}
(Type::Int): s32 value [[name(name)]];
(Type::Long): s64 value [[name(name)]];
(Type::Single): float value [[name(name)]];
(Type::Double): double value [[name(name)]];
(Type::Guid): GUID value [[name(name)]];
(Type::Sha1): SHA1 value [[name(name)]];
(Type::ByteArray):
{
type::uLEB128 size [[hidden]];
u8 value[size] [[name(name)]];
}
}
} [[inline]];
}
struct DbObject : DbObject::DbObjectElement
{
};
}