Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Readable.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2//
3// This code was automatically generated by the joedb compiler
4// https://www.joedb.org/
5//
6// Path to compiler: /home/rcoulom/repos/joedb/doc/source/tutorial/build/joedbc
7// Version: 9.1.4
8// joedbc compilation time: Apr 15 2025 14:46:29
9// Generation of this file: 2025-04-15 12:46:31 GMT
10//
11/////////////////////////////////////////////////////////////////////////////
12#ifndef settings_Readable_declared
13#define settings_Readable_declared
14
15#include "Database.h"
16
19
20namespace settings
21{
22 /// Implement the @ref joedb::Readable interface for a compiled database
23 ///
24 /// This allows using a compiled database with tools such as the
25 /// command interpreter.
27 {
28 private:
29 const Database &db;
30
31 public:
32 Readable(const Database &db): db(db)
33 {
34 joedb::Readonly_Memory_File file(detail::schema_string, detail::schema_string_size);
35 joedb::Readonly_Journal journal(file);
36 journal.replay_log(*this);
37 }
38
40 (
41 Table_Id table_id
42 ) const override
43 {
44 if (table_id == Table_Id{1})
45 return db.storage_of_settings.freedom_keeper;
46
47 throw joedb::Exception("unknown table_id");
48 }
49
50 const std::string& get_string
51 (
52 Table_Id table_id,
53 Record_Id record_id,
54 Field_Id field_id
55 ) const override
56 {
57 if (table_id == Table_Id{1})
58 {
59 if (field_id == Field_Id(2))
60 {
61 return db.storage_of_settings.field_value_of_host[size_t(record_id) - 1];
62 }
63 if (field_id == Field_Id(3))
64 {
65 return db.storage_of_settings.field_value_of_user[size_t(record_id) - 1];
66 }
67 }
68
69 throw joedb::Exception("unknown field");
70 }
71
72 const int32_t& get_int32
73 (
74 Table_Id table_id,
75 Record_Id record_id,
76 Field_Id field_id
77 ) const override
78 {
79 throw joedb::Exception("unknown field");
80 }
81
82 const int64_t& get_int64
83 (
84 Table_Id table_id,
85 Record_Id record_id,
86 Field_Id field_id
87 ) const override
88 {
89 throw joedb::Exception("unknown field");
90 }
91
93 (
94 Table_Id table_id,
95 Record_Id record_id,
96 Field_Id field_id
97 ) const override
98 {
99 throw joedb::Exception("unknown field");
100 }
101
102 const char& get_boolean
103 (
104 Table_Id table_id,
105 Record_Id record_id,
106 Field_Id field_id
107 ) const override
108 {
109 if (table_id == Table_Id{1})
110 {
111 if (field_id == Field_Id(1))
112 {
113 return db.storage_of_settings.field_value_of_dark_mode[size_t(record_id) - 1];
114 }
115 }
116
117 throw joedb::Exception("unknown field");
118 }
119
120 const float& get_float32
121 (
122 Table_Id table_id,
123 Record_Id record_id,
124 Field_Id field_id
125 ) const override
126 {
127 throw joedb::Exception("unknown field");
128 }
129
130 const double& get_float64
131 (
132 Table_Id table_id,
133 Record_Id record_id,
134 Field_Id field_id
135 ) const override
136 {
137 throw joedb::Exception("unknown field");
138 }
139
140 const int8_t& get_int8
141 (
142 Table_Id table_id,
143 Record_Id record_id,
144 Field_Id field_id
145 ) const override
146 {
147 throw joedb::Exception("unknown field");
148 }
149
150 const int16_t& get_int16
151 (
152 Table_Id table_id,
153 Record_Id record_id,
154 Field_Id field_id
155 ) const override
156 {
157 throw joedb::Exception("unknown field");
158 }
159
161 (
162 Table_Id table_id,
163 Record_Id record_id,
164 Field_Id field_id
165 ) const override
166 {
167 throw joedb::Exception("unknown field");
168 }
169 };
170
171 namespace interpreted_settings
172 {
173 constexpr static Table_Id table_id = Table_Id{1};
174 constexpr static Field_Id dark_mode_field_id = Field_Id{1};
175 constexpr static Field_Id host_field_id = Field_Id{2};
176 constexpr static Field_Id user_field_id = Field_Id{3};
177 }
178}
179
180#endif
void replay_log(Writable &writable)
Store all the tables of the database.
Definition Database.h:76
detail::data_of_settings storage_of_settings
Definition Database.h:99
Implement the joedb::Readable interface for a compiled database.
Definition Readable.h:27
const std::string & get_string(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:51
Readable(const Database &db)
Definition Readable.h:32
const int32_t & get_int32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:73
const float & get_float32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:121
const int64_t & get_int64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:83
const joedb::Blob & get_blob(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:161
const char & get_boolean(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:103
const joedb::Compact_Freedom_Keeper & get_freedom(Table_Id table_id) const override
Definition Readable.h:40
const int8_t & get_int8(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:141
const int16_t & get_int16(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:151
const double & get_float64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:131
const joedb::Record_Id & get_reference(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:93
Automatically generated by joedbc.
Definition Client.h:19