7 void ids_h::write_hashing(std::ostream &out)
13 for (
const auto &[tid, tname]: tables)
15 if (!(parent_options && parent_options->
has_table(tname)))
17 out <<
" template<>\n";
18 out <<
" struct hash<";
20 out <<
"::id_of_" << tname <<
">\n";
22 out <<
" size_t operator()(";
24 out <<
"::id_of_" << tname <<
" x) const noexcept\n";
26 out <<
" return hash<joedb::index_t>{}(x.get_id());\n";
41 parent_options(parent_options)
61#include "joedb/index_types.h"
68 using joedb::Record_Id;
69 using joedb::Table_Id;
70 using joedb::Field_Id;
73 for (
const auto &[tid, tname]: tables)
76 if (parent_options && parent_options->
has_table(tname))
78 out <<
" using id_of_" << tname <<
" = ";
80 out <<
"::id_of_" << tname <<
";\n";
84 out <<
" /// Strongly-typed wrapper around an integer representing a row of the " << tname <<
" table\n";
85 out <<
" class id_of_" << tname <<
"\n {\n";
87 out <<
" Record_Id id;\n";
88 out <<
"\n public:\n";
89 out <<
" constexpr explicit id_of_" << tname <<
"(joedb::index_t id): id(Record_Id(id)) {}\n";
90 out <<
" constexpr explicit id_of_" << tname <<
"(Record_Id id): id(id) {}\n";
91 out <<
" constexpr id_of_" << tname <<
"(): id(joedb::Record_Id::null) {}\n";
92 out <<
" constexpr bool is_null() const {return id.is_null();}\n";
93 out <<
" constexpr bool is_not_null() const {return id.is_not_null();}\n";
94 out <<
" constexpr auto get_id() const {return to_underlying(id);}\n";
95 out <<
" constexpr Record_Id get_record_id() const {return id;}\n";
96 out <<
" constexpr bool operator==(id_of_" << tname <<
" x) const {return id == x.id;}\n";
97 out <<
" constexpr bool operator!=(id_of_" << tname <<
" x) const {return id != x.id;}\n";
98 out <<
" constexpr bool operator<(id_of_" << tname <<
" x) const {return id < x.id;}\n";
99 out <<
" constexpr bool operator>(id_of_" << tname <<
" x) const {return id > x.id;}\n";
100 out <<
" constexpr bool operator<=(id_of_" << tname <<
" x) const {return id <= x.id;}\n";
101 out <<
" constexpr bool operator>=(id_of_" << tname <<
" x) const {return id >= x.id;}\n";
102 out <<
" constexpr id_of_" << tname <<
" operator[](size_t i) const {return id_of_" << tname <<
"(id + i);}\n";
109 out <<
"\n#include <functional>\n\n";
110 out <<
"namespace std\n{\n";
std::vector< std::string > name_space
const std::vector< std::string > & get_name_space() const
const Database & get_db() const
bool has_table(const std::string &table_name) const
const std::map< Table_Id, std::string > & get_tables() const override
const Compiler_Options & options
ids_h(const Compiler_Options &options, const Compiler_Options *parent_options)
void write(std::ostream &out) override
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_write(std::ostream &out, const std::vector< std::string > &n, const char *delimiter)
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.