Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
SQL_Dump_Writable.h
Go to the documentation of this file.
1#ifndef joedb_SQL_Dump_Writable_declared
2#define joedb_SQL_Dump_Writable_declared
3
5#include "joedb/Multiplexer.h"
6
7namespace joedb
8{
9 class Buffered_File;
10
11 /// @ingroup ui
12 class SQL_Writable: public Writable
13 {
14 private:
15 static constexpr const char *id_field_name = "\"__id\"";
16 static constexpr const char *key_type = "INTEGER";
17
18 std::ostream &out;
19 const Database_Schema &schema;
20 const Buffered_File *blob_reader;
21 const bool drop_column;
22
23 void write_type(Type type);
24 void write_update(Table_Id table_id, Field_Id field_id);
25 void write_where(Record_Id record_id);
26
27 public:
29 (
30 std::ostream &out,
31 const Database_Schema &schema,
32 const Buffered_File *blob_reader = nullptr,
33 bool drop_column = true
34 ):
35 out(out),
36 schema(schema),
37 blob_reader(blob_reader),
38 drop_column(drop_column)
39 {}
40
41 const char *get_name() const {return "sql";}
42
43 void start_writing(int64_t position);
44 void soft_checkpoint_at(int64_t position);
45
46 void create_table(const std::string &name) final;
47 void drop_table(Table_Id table_id) final;
48 void rename_table(Table_Id table_id, const std::string &name) final;
49 void add_field
50 (
51 Table_Id table_id,
52 const std::string &name,
53 Type type
54 ) final;
55 void drop_field(Table_Id table_id, Field_Id field_id) final;
56 void rename_field
57 (
58 Table_Id table_id,
59 Field_Id field_id,
60 const std::string &name
61 ) final;
62 void custom(const std::string &name) final;
63 void comment(const std::string &comment) final;
64 void timestamp(int64_t timestamp) final;
65 void valid_data() final;
66 void insert_into(Table_Id table_id, Record_Id record_id) final;
67 void delete_from(Table_Id table_id, Record_Id record_id) final;
68
69 #define TYPE_MACRO(type, return_type, type_id, R, W)\
70 void update_##type_id(Table_Id table_id,\
71 Record_Id record_id,\
72 Field_Id field_id,\
73 return_type value) final;
74 #include "joedb/TYPE_MACRO.h"
75
77 };
78
80 {
81 protected:
84
85 public:
87 (
88 std::ostream &out,
89 const Buffered_File *blob_reader = nullptr,
90 bool drop_column = true
91 ):
92 interpreter_writable(out, schema, blob_reader, drop_column)
93 {
94 }
95 };
96
99 public Multiplexer
100 {
101 public:
103 (
104 std::ostream &out,
105 const Buffered_File *blob_reader = nullptr,
106 bool drop_column = true
107 ):
108 SQL_Dump_Writable_Parent(out, blob_reader, drop_column),
110 {
111 }
112 };
113}
114
115#endif
SQL_Dump_Writable_Parent(std::ostream &out, const Buffered_File *blob_reader=nullptr, bool drop_column=true)
SQL_Dump_Writable(std::ostream &out, const Buffered_File *blob_reader=nullptr, bool drop_column=true)
void drop_table(Table_Id table_id) final
void insert_into(Table_Id table_id, Record_Id record_id) final
void custom(const std::string &name) final
void rename_field(Table_Id table_id, Field_Id field_id, const std::string &name) final
void timestamp(int64_t timestamp) final
void delete_from(Table_Id table_id, Record_Id record_id) final
void drop_field(Table_Id table_id, Field_Id field_id) final
void add_field(Table_Id table_id, const std::string &name, Type type) final
void soft_checkpoint_at(int64_t position)
const char * get_name() const
void comment(const std::string &comment) final
void rename_table(Table_Id table_id, const std::string &name) final
void start_writing(int64_t position)
void create_table(const std::string &name) final
SQL_Writable(std::ostream &out, const Database_Schema &schema, const Buffered_File *blob_reader=nullptr, bool drop_column=true)
Definition Blob.h:7