Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
index_types.h
Go to the documentation of this file.
1#ifndef joedb_index_types_declared
2#define joedb_index_types_declared
3
4#include <stdint.h>
5#include <stdlib.h>
6#include <type_traits>
7
8namespace joedb
9{
10 enum class Table_Id: uint16_t {};
11 enum class Field_Id: uint16_t {};
12 enum class Record_Id: size_t {};
13
14 constexpr inline std::underlying_type<Table_Id>::type to_underlying
15 (
16 Table_Id id
17 )
18 {
19 return std::underlying_type<Table_Id>::type(id);
20 }
21
22 constexpr inline std::underlying_type<Field_Id>::type to_underlying
23 (
24 Field_Id id
25 )
26 {
27 return std::underlying_type<Field_Id>::type(id);
28 }
29
30 constexpr inline std::underlying_type<Record_Id>::type to_underlying
31 (
32 Record_Id id
33 )
34 {
35 return std::underlying_type<Record_Id>::type(id);
36 }
37
38 constexpr inline Record_Id operator+(Record_Id id, size_t size)
39 {
40 return Record_Id(to_underlying(id) + size);
41 }
42 constexpr inline Record_Id operator-(Record_Id id, size_t size)
43 {
44 return Record_Id(to_underlying(id) - size);
45 }
46
48 {
49 return id = Table_Id(to_underlying(id) + 1);
50 }
52 {
53 return id = Field_Id(to_underlying(id) + 1);
54 }
56 {
57 return id = id + 1;
58 }
60 {
61 return id = id - 1;
62 }
63}
64
65#endif
Definition Blob.h:7
constexpr std::underlying_type< Table_Id >::type to_underlying(Table_Id id)
Definition index_types.h:15
constexpr Record_Id operator-(Record_Id id, size_t size)
Definition index_types.h:42
Record_Id & operator--(Record_Id &id)
Definition index_types.h:59
Table_Id & operator++(Table_Id &id)
Definition index_types.h:47
constexpr Record_Id operator+(Record_Id id, size_t size)
Definition index_types.h:38