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 joedb_db_multi_server_Readable_declared
13#define joedb_db_multi_server_Readable_declared
14
15#include "Database.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_server.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(1))
60 {
61 return db.storage_of_server.field_value_of_file_name[size_t(record_id) - 1];
62 }
63 }
64
65 throw joedb::Exception("unknown field");
66 }
67
68 const int32_t& get_int32
69 (
70 Table_Id table_id,
71 Record_Id record_id,
72 Field_Id field_id
73 ) const override
74 {
75 if (table_id == Table_Id{1})
76 {
77 if (field_id == Field_Id(2))
78 {
79 return db.storage_of_server.field_value_of_port[size_t(record_id) - 1];
80 }
81 if (field_id == Field_Id(3))
82 {
83 return db.storage_of_server.field_value_of_timeout[size_t(record_id) - 1];
84 }
85 }
86
87 throw joedb::Exception("unknown field");
88 }
89
90 const int64_t& get_int64
91 (
92 Table_Id table_id,
93 Record_Id record_id,
94 Field_Id field_id
95 ) const override
96 {
97 throw joedb::Exception("unknown field");
98 }
99
101 (
102 Table_Id table_id,
103 Record_Id record_id,
104 Field_Id field_id
105 ) const override
106 {
107 throw joedb::Exception("unknown field");
108 }
109
110 const char& get_boolean
111 (
112 Table_Id table_id,
113 Record_Id record_id,
114 Field_Id field_id
115 ) const override
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_server
172 {
173 constexpr static Table_Id table_id = Table_Id{1};
174 constexpr static Field_Id file_name_field_id = Field_Id{1};
175 constexpr static Field_Id port_field_id = Field_Id{2};
176 constexpr static Field_Id timeout_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:82
detail::data_of_server storage_of_server
Definition Database.h:105
Implement the joedb::Readable interface for a compiled database.
Definition Readable.h:27
const int32_t & get_int32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:69
const std::string & get_string(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:51
const float & get_float32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:121
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
Readable(const Database &db)
Definition Readable.h:32
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:111
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:101
const int64_t & get_int64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:91
Automatically generated by joedbc.
Definition Client.h:19