Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Signatures_h.cpp
Go to the documentation of this file.
3
4#include <set>
5
6namespace joedb::generator
7{
9 (
10 const Compiler_Options &options,
11 const std::vector<Procedure> &procedures
12 ):
13 Generator(".", "rpc/Signatures.h", options),
14 procedures(procedures)
15 {
16 }
17
19 {
20 auto name_space = options.get_name_space();
21 name_space.emplace_back("rpc");
22
23 namespace_include_guard_open(out, "Signatures", name_space);
24 out << "\n#include \"joedb/rpc/Signature.h\"\n";
25
26 {
27 std::set<std::string> schemas;
28
29 for (const auto &procedure: procedures)
30 schemas.insert(procedure.schema);
31
32 for (const auto &schema: schemas)
33 out << "#include \"" << options.get_path(schema) << "/Memory_Database.h\"\n";
34 }
35
36 out << '\n';
37 namespace_open(out, name_space);
38
39 out << R"RRR(
40 /// Get the list of procedure signatures. Used by RPC client and server.
41 inline const auto &get_signatures()
42 {
43 static const std::vector<joedb::rpc::Signature> signatures
44 {
45)RRR";
46
47 for (const auto &procedure: procedures)
48 {
49 out << " {\"" << procedure.name << "\", " << procedure.schema;
50 out << "::Memory_Database().get_data()},\n";
51 }
52
53 out << " };\n\n";
54 out << " return signatures;\n";
55 out << " }\n";
56
57 namespace_close(out, name_space);
59 }
60}
std::string get_path(const std::string &schema) const
const std::vector< std::string > & get_name_space() const
const Compiler_Options & options
Definition Generator.h:13
Signatures_h(const Compiler_Options &options, const std::vector< Procedure > &procedures)
void namespace_open(std::ostream &out, const std::vector< std::string > &n)
void namespace_close(std::ostream &out, const std::vector< std::string > &n)
void namespace_include_guard_open(std::ostream &out, const char *name, const std::vector< std::string > &n)
void namespace_include_guard_close(std::ostream &out)
One code generator for each of the file generated by joedbc.
Definition Client_h.cpp:5