Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Database_Schema.h
Go to the documentation of this file.
1#ifndef joedb_Database_Schema_declared
2#define joedb_Database_Schema_declared
3
4#include "joedb/Readable.h"
5#include "joedb/Writable.h"
7
8#include <map>
9
10namespace joedb
11{
12 /// @ingroup interpreted
13 class Database_Schema: public Readable, public Writable
14 {
15 protected:
16 std::map<Table_Id, Table> tables;
17 std::map<Table_Id, std::string> table_names;
19
20 static void check_identifier
21 (
22 const char *message,
23 const std::string &name
24 );
25
26 const Table& get_table(Table_Id table_id) const;
27 Table& get_table(Table_Id table_id);
28
29 public:
30 //
31 // Readable override
32 //
33 const std::map<Table_Id, std::string> &get_tables() const override
34 {
35 return table_names;
36 }
37
38 const std::map<Field_Id, std::string> &get_fields
39 (
40 Table_Id table_id
41 ) const override;
42
43 const Type &get_field_type
44 (
45 Table_Id table_id,
46 Field_Id field_id
47 ) const override;
48
49 const Compact_Freedom_Keeper &get_freedom(Table_Id table_id) const override;
50
51 #define TYPE_MACRO(type, return_type, type_id, R, W)\
52 const type &get_##type_id\
53 (\
54 Table_Id table_id,\
55 Record_Id record_id,\
56 Field_Id field_id\
57 ) const override;
58 #include "joedb/TYPE_MACRO.h"
59
60 //
61 // Writable override
62 //
63 void create_table(const std::string &name) override;
64 void drop_table(Table_Id table_id) override;
65 void rename_table(Table_Id table_id, const std::string &name) override;
66 void add_field
67 (
68 Table_Id table_id,
69 const std::string &name,
70 Type type
71 ) override;
72 void drop_field(Table_Id table_id, Field_Id field_id) override;
73 void rename_field(Table_Id, Field_Id, const std::string &name) override;
74
75 virtual ~Database_Schema() override;
76 };
77}
78
79#endif
std::map< Table_Id, std::string > table_names
void create_table(const std::string &name) override
const Table & get_table(Table_Id table_id) const
static void check_identifier(const char *message, const std::string &name)
virtual ~Database_Schema() override
void drop_table(Table_Id table_id) override
void add_field(Table_Id table_id, const std::string &name, Type type) override
const Compact_Freedom_Keeper & get_freedom(Table_Id table_id) const override
void rename_field(Table_Id, Field_Id, const std::string &name) override
void rename_table(Table_Id table_id, const std::string &name) override
const std::map< Table_Id, std::string > & get_tables() const override
void drop_field(Table_Id table_id, Field_Id field_id) override
std::map< Table_Id, Table > tables
const Type & get_field_type(Table_Id table_id, Field_Id field_id) const override
const std::map< Field_Id, std::string > & get_fields(Table_Id table_id) const override
Definition Blob.h:7