26#include "joedb/index_types.h"
33 using joedb::Record_Id;
34 using joedb::Table_Id;
35 using joedb::Field_Id;
38 for (
const auto &[tid, tname]: tables)
41 out <<
" /// Strongly-typed wrapper around an integer representing a row of the " << tname <<
" table\n";
42 out <<
" class id_of_" << tname <<
"\n {\n";
44 out <<
" Record_Id id;\n";
45 out <<
"\n public:\n";
46 out <<
" constexpr explicit id_of_" << tname <<
"(size_t id): id(Record_Id(id)) {}\n";
47 out <<
" constexpr explicit id_of_" << tname <<
"(Record_Id id): id(id) {}\n";
48 out <<
" constexpr id_of_" << tname <<
"(): id(Record_Id(0)) {}\n";
49 out <<
" constexpr bool is_null() const {return id == Record_Id(0);}\n";
50 out <<
" constexpr bool is_not_null() const {return id != Record_Id(0);}\n";
51 out <<
" constexpr size_t get_id() const {return size_t(id);}\n";
52 out <<
" constexpr Record_Id get_record_id() const {return id;}\n";
53 out <<
" constexpr bool operator==(id_of_" << tname <<
" x) const {return id == x.id;}\n";
54 out <<
" constexpr bool operator!=(id_of_" << tname <<
" x) const {return id != x.id;}\n";
55 out <<
" constexpr bool operator<(id_of_" << tname <<
" x) const {return id < x.id;}\n";
56 out <<
" constexpr bool operator>(id_of_" << tname <<
" x) const {return id > x.id;}\n";
57 out <<
" constexpr bool operator<=(id_of_" << tname <<
" x) const {return id <= x.id;}\n";
58 out <<
" constexpr bool operator>=(id_of_" << tname <<
" x) const {return id >= x.id;}\n";
59 out <<
" constexpr id_of_" << tname <<
" operator[](size_t i) const {return id_of_" << tname <<
"(id + i);}\n";
const std::vector< std::string > & get_name_space() const
const Database & get_db() const
const std::map< Table_Id, std::string > & get_tables() const override
const Compiler_Options & options
ids_h(const Compiler_Options &options)
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(std::ostream &out, const char *name, const std::vector< std::string > &n)
One code generator for each of the file generated by joedbc.