Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Type.h
Go to the documentation of this file.
1#ifndef joedb_Type_declared
2#define joedb_Type_declared
3
4#include "joedb/index_types.h"
5#include "joedb/Blob.h"
6
7#include <string>
8
9namespace joedb
10{
11 typedef uint8_t Type_Id_Storage;
12
13 class Type
14 {
15 public:
16 enum class Type_Id: uint8_t
17 {
18 null,
19 #define TYPE_MACRO(a, b, c, d, e) c,
20 #include "joedb/TYPE_MACRO.h"
21 };
22
23 #define TYPE_MACRO(a, b, c, d, e) 1 +
24 enum {type_ids =
25 #include "joedb/TYPE_MACRO.h"
26 1
27 };
28
29 private:
30 Type_Id type_id;
31 Table_Id table_id;
32
33 Type(Type_Id type_id,
34 Table_Id table_id):
35 type_id(type_id),
36 table_id(table_id)
37 {}
38
39 public:
40 Type_Id get_type_id() const {return type_id;}
41 Table_Id get_table_id() const {return table_id;}
42
43 Type(): type_id(Type_Id::null), table_id{0} {}
44 Type(Type_Id type_id): type_id(type_id), table_id{0} {}
45
46 #define TYPE_MACRO(type, return_type, type_id, read, write)\
47 static Type type_id() {return Type(Type_Id::type_id);};
48 #define TYPE_MACRO_NO_REFERENCE
49 #include "joedb/TYPE_MACRO.h"
50
51 static Type reference(Table_Id table_id)
52 {
53 return Type(Type_Id::reference, table_id);
54 }
55 };
56}
57
58#endif
Type(Type_Id type_id)
Definition Type.h:44
static Type reference(Table_Id table_id)
Definition Type.h:51
Table_Id get_table_id() const
Definition Type.h:41
Type_Id get_type_id() const
Definition Type.h:40
@ type_ids
Definition Type.h:24
Definition Blob.h:7
uint8_t Type_Id_Storage
Definition Type.h:11