Joedb 9.5.0
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 <stddef.h>
6#include <stdlib.h>
7#include <type_traits>
8
9namespace joedb
10{
11 /// @ingroup joedb
12 enum class Table_Id: uint16_t {};
13
14 /// @ingroup joedb
15 enum class Field_Id: uint16_t {};
16
17 /// @ingroup joedb
18 enum class Record_Id: ptrdiff_t {};
19
20 constexpr inline std::underlying_type<Table_Id>::type to_underlying
21 (
22 Table_Id id
23 )
24 {
25 return std::underlying_type<Table_Id>::type(id);
26 }
27
28 constexpr inline std::underlying_type<Field_Id>::type to_underlying
29 (
30 Field_Id id
31 )
32 {
33 return std::underlying_type<Field_Id>::type(id);
34 }
35
36 constexpr inline std::underlying_type<Record_Id>::type to_underlying
37 (
38 Record_Id id
39 )
40 {
41 return std::underlying_type<Record_Id>::type(id);
42 }
43
44 constexpr inline Record_Id operator+(Record_Id id, size_t size)
45 {
46 return Record_Id(to_underlying(id) + size);
47 }
48 constexpr inline Record_Id operator-(Record_Id id, size_t size)
49 {
50 return Record_Id(to_underlying(id) - size);
51 }
52
54 {
55 return id = Table_Id(to_underlying(id) + 1);
56 }
58 {
59 return id = Field_Id(to_underlying(id) + 1);
60 }
62 {
63 return id = id + 1;
64 }
66 {
67 return id = id - 1;
68 }
69}
70
71#endif
Definition Blob.h:7
constexpr std::underlying_type< Table_Id >::type to_underlying(Table_Id id)
Definition index_types.h:21
constexpr Record_Id operator-(Record_Id id, size_t size)
Definition index_types.h:48
Record_Id & operator--(Record_Id &id)
Definition index_types.h:65
Table_Id & operator++(Table_Id &id)
Definition index_types.h:53
constexpr Record_Id operator+(Record_Id id, size_t size)
Definition index_types.h:44