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_encoded_file_Readable_declared
13#define joedb_db_encoded_file_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_buffer.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 throw joedb::Exception("unknown field");
58 }
59
60 const int32_t& get_int32
61 (
62 Table_Id table_id,
63 Record_Id record_id,
64 Field_Id field_id
65 ) const override
66 {
67 throw joedb::Exception("unknown field");
68 }
69
70 const int64_t& get_int64
71 (
72 Table_Id table_id,
73 Record_Id record_id,
74 Field_Id field_id
75 ) const override
76 {
77 if (table_id == Table_Id{1})
78 {
79 if (field_id == Field_Id(2))
80 {
81 return db.storage_of_buffer.field_value_of_size[size_t(record_id) - 1];
82 }
83 if (field_id == Field_Id(3))
84 {
85 return db.storage_of_buffer.field_value_of_offset[size_t(record_id) - 1];
86 }
87 }
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 throw joedb::Exception("unknown field");
110 }
111
112 const float& get_float32
113 (
114 Table_Id table_id,
115 Record_Id record_id,
116 Field_Id field_id
117 ) const override
118 {
119 throw joedb::Exception("unknown field");
120 }
121
122 const double& get_float64
123 (
124 Table_Id table_id,
125 Record_Id record_id,
126 Field_Id field_id
127 ) const override
128 {
129 throw joedb::Exception("unknown field");
130 }
131
132 const int8_t& get_int8
133 (
134 Table_Id table_id,
135 Record_Id record_id,
136 Field_Id field_id
137 ) const override
138 {
139 throw joedb::Exception("unknown field");
140 }
141
142 const int16_t& get_int16
143 (
144 Table_Id table_id,
145 Record_Id record_id,
146 Field_Id field_id
147 ) const override
148 {
149 throw joedb::Exception("unknown field");
150 }
151
153 (
154 Table_Id table_id,
155 Record_Id record_id,
156 Field_Id field_id
157 ) const override
158 {
159 if (table_id == Table_Id{1})
160 {
161 if (field_id == Field_Id(1))
162 {
163 return db.storage_of_buffer.field_value_of_data[size_t(record_id) - 1];
164 }
165 }
166
167 throw joedb::Exception("unknown field");
168 }
169 };
170
171 namespace interpreted_buffer
172 {
173 constexpr static Table_Id table_id = Table_Id{1};
174 constexpr static Field_Id data_field_id = Field_Id{1};
175 constexpr static Field_Id size_field_id = Field_Id{2};
176 constexpr static Field_Id offset_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:75
detail::data_of_buffer storage_of_buffer
Definition Database.h:98
Implement the joedb::Readable interface for a compiled database.
Definition Readable.h:27
const float & get_float32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:113
const double & get_float64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:123
const joedb::Compact_Freedom_Keeper & get_freedom(Table_Id table_id) const override
Definition Readable.h:40
const char & get_boolean(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:103
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:153
const std::string & get_string(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:51
const joedb::Record_Id & get_reference(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:93
const int8_t & get_int8(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:133
const int16_t & get_int16(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:143
const int32_t & get_int32(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:61
const int64_t & get_int64(Table_Id table_id, Record_Id record_id, Field_Id field_id) const override
Definition Readable.h:71
Automatically generated by joedbc.
Definition Client.h:19