Joedb 9.1.4
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 create_table(const std::string &name) final;
44 void drop_table(Table_Id table_id) final;
45 void rename_table(Table_Id table_id, const std::string &name) final;
46 void add_field
47 (
48 Table_Id table_id,
49 const std::string &name,
50 Type type
51 ) final;
52 void drop_field(Table_Id table_id, Field_Id field_id) final;
53 void rename_field
54 (
55 Table_Id table_id,
56 Field_Id field_id,
57 const std::string &name
58 ) final;
59 void custom(const std::string &name) final;
60 void comment(const std::string &comment) final;
61 void timestamp(int64_t timestamp) final;
62 void valid_data() final;
63 void insert_into(Table_Id table_id, Record_Id record_id) final;
64 void insert_vector(Table_Id table_id,
65 Record_Id record_id,
66 size_t size) 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 insert_vector(Table_Id table_id, Record_Id record_id, size_t size) 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
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 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