Joedb 10.2.1
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/compcmake/gcc_debug/joedbc
7// Version: 10.2.1
8// joedbc compilation time: Sep 15 2025 20:22:33
9// Generation of this file: 2025-09-15 18:23:01 GMT
10//
11/////////////////////////////////////////////////////////////////////////////
12#ifndef tutorial_rpc_population_Readable_declared
13#define tutorial_rpc_population_Readable_declared
14
15#include "Database_Writable.h"
16
19
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_city.freedom_keeper;
46 if (table_id == Table_Id{2})
47 return db.storage_of_data.freedom_keeper;
48
49 throw joedb::Exception("unknown table_id");
50 }
51
52 const std::string& get_string
53 (
54 Table_Id table_id,
55 Record_Id record_id,
56 Field_Id field_id
57 ) const override
58 {
59 if (table_id == Table_Id{2})
60 {
61 if (field_id == Field_Id(1))
62 {
63 return db.storage_of_data.field_value_of_city_name[to_underlying(record_id)];
64 }
65 }
66
67 throw joedb::Exception("unknown field");
68 }
69
70 const int32_t& get_int32
71 (
72 Table_Id table_id,
73 Record_Id record_id,
74 Field_Id field_id
75 ) const override
76 {
77 throw joedb::Exception("unknown field");
78 }
79
80 const int64_t& get_int64
81 (
82 Table_Id table_id,
83 Record_Id record_id,
84 Field_Id field_id
85 ) const override
86 {
87 if (table_id == Table_Id{2})
88 {
89 if (field_id == Field_Id(3))
90 {
91 return db.storage_of_data.field_value_of_population[to_underlying(record_id)];
92 }
93 }
94
95 throw joedb::Exception("unknown field");
96 }
97
99 (
100 Table_Id table_id,
101 Record_Id record_id,
102 Field_Id field_id
103 ) const override
104 {
105 if (table_id == Table_Id{2})
106 {
107 if (field_id == Field_Id(2))
108 {
109 return *reinterpret_cast<const joedb::Record_Id *>(&db.storage_of_data.field_value_of_city[to_underlying(record_id)]);
110 }
111 }
112
113 throw joedb::Exception("unknown field");
114 }
115
116 const char& get_boolean
117 (
118 Table_Id table_id,
119 Record_Id record_id,
120 Field_Id field_id
121 ) const override
122 {
123 throw joedb::Exception("unknown field");
124 }
125
126 const float& get_float32
127 (
128 Table_Id table_id,
129 Record_Id record_id,
130 Field_Id field_id
131 ) const override
132 {
133 throw joedb::Exception("unknown field");
134 }
135
136 const double& get_float64
137 (
138 Table_Id table_id,
139 Record_Id record_id,
140 Field_Id field_id
141 ) const override
142 {
143 throw joedb::Exception("unknown field");
144 }
145
146 const int8_t& get_int8
147 (
148 Table_Id table_id,
149 Record_Id record_id,
150 Field_Id field_id
151 ) const override
152 {
153 throw joedb::Exception("unknown field");
154 }
155
156 const int16_t& get_int16
157 (
158 Table_Id table_id,
159 Record_Id record_id,
160 Field_Id field_id
161 ) const override
162 {
163 throw joedb::Exception("unknown field");
164 }
165
167 (
168 Table_Id table_id,
169 Record_Id record_id,
170 Field_Id field_id
171 ) const override
172 {
173 throw joedb::Exception("unknown field");
174 }
175 };
176
177 namespace city_table
178 {
179 constexpr static Table_Id id{1};
180
181 }
182 namespace data_table
183 {
184 constexpr static Table_Id id{2};
185
186 namespace city_name_field
187 {
188 constexpr static Field_Id id{1};
189 }
190 namespace city_field
191 {
192 constexpr static Field_Id id{2};
193 }
194 namespace population_field
195 {
196 constexpr static Field_Id id{3};
197 }
198 }
199}
200
201#endif
void replay_log(Writable &writable)
Store all the tables of the database.
Definition Database.h:81
detail::data_of_data storage_of_data
Definition Database.h:99
detail::data_of_city storage_of_city
Definition Database.h:97
Implement the joedb::Readable interface for a compiled database.
Definition Readable.h:27
const joedb::Blob & get_blob(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:167
Readable(const Database &db)
Definition Readable.h:32
const double & get_float64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:137
const int32_t & get_int32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:71
const int64_t & get_int64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:81
const std::string & get_string(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:53
const float & get_float32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:127
const joedb::Record_Id & get_reference(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:99
const char & get_boolean(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:117
const int16_t & get_int16(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:157
const int8_t & get_int8(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:147
const joedb::Freedom_Keeper & get_freedom(Table_Id table_id) const override
Definition Readable.h:40
Automatically generated by joedbc.
Definition Client.h:19