14 for (
const auto &[tid, tname]:
options.db.get_tables())
26 for (
const auto &[fid, fname]:
options.db.get_fields(table_id))
27 if (
options.db.get_field_type(table_id, fid).get_type_id() == type_id)
36 out <<
"/////////////////////////////////////////////////////////////////////////////\n";
38 out <<
"// This code was automatically generated by the joedb compiler\n";
39 out <<
"// https://www.joedb.org/\n";
41 out <<
"// Path to compiler: " <<
options.exe_path <<
'\n';
43 out <<
"// joedbc compilation time: " << __DATE__
" " __TIME__
"\n";
46 out <<
"/////////////////////////////////////////////////////////////////////////////\n";
59 switch (type.get_type_id())
66 out <<
"id_of_" <<
options.db.get_table_name(type.get_table_id());
71 out <<
"const std::string &";
73 out <<
"std::string_view";
78 #define TYPE_MACRO(storage_tt, return_tt, type_id, read, write)\
79 case Type::Type_Id::type_id:\
80 if (return_type || setter_type)\
85 #define TYPE_MACRO_NO_REFERENCE
86 #define TYPE_MACRO_NO_STRING
100 if (index.field_ids.size() > 1)
102 out <<
"std::tuple<";
104 for (
size_t i = 0; i < index.field_ids.size(); i++)
127 options.db.get_field_type(index.table_id, index.field_ids[0]),
138 #define STRINGIFY(X) #X
139 #define EXPAND_AND_STRINGIFY(X) STRINGIFY(X)
145 static constexpr char const *
const types[] =
148 #define TYPE_MACRO(a, b, type_id, d, e) EXPAND_AND_STRINGIFY(type_id),
159 static char const *
const cpp_types[] =
162 #define TYPE_MACRO(a, type, c, d, e) EXPAND_AND_STRINGIFY(type),
173 static char const *
const storage_types[] =
176 #define TYPE_MACRO(storage, b, c, d, e) EXPAND_AND_STRINGIFY(storage),
183 #undef EXPAND_AND_STRINGIFY
204 const std::string dir_string =
206 options.get_name_space_back() +
"/" +
Type_Id get_type_id() const
static const char * get_storage_type_string(Type type)
static const char * get_type_string(Type type)
static const char * get_cpp_type_string(Type type)
const std::string file_name
const Compiler_Options & options
const std::string dir_name
virtual void write(std::ostream &out)=0
bool db_has_values() const
void write_tuple_type(std::ostream &out, const Compiler_Options::Index &index, bool reference)
void write_initial_comment(std::ostream &out)
bool table_has_field_type(Table_Id table_id, Type::Type_Id type_id) const
Generator(std::string dir_name, std::string file_name, const Compiler_Options &options)
void write_type(std::ostream &out, Type type, bool return_type, bool setter_type)
constexpr const char * get_version()
std::string get_time_string_of_now()
One code generator for each of the file generated by joedbc.
void write_source_code(const std::string &dir_name, const std::string &file_name, const std::function< void(std::ostream &)> &write)