26 out <<
"/////////////////////////////////////////////////////////////////////////////\n";
28 out <<
"// This code was automatically generated by the joedb compiler\n";
29 out <<
"// https://www.joedb.org/\n";
33 out <<
"// joedbc compilation time: " << __DATE__
" " __TIME__
"\n";
36 out <<
"/////////////////////////////////////////////////////////////////////////////\n";
49 switch (type.get_type_id())
55 case Type::Type_Id::reference:
56 out <<
"id_of_" << options.db.get_table_name(type.get_table_id());
59 case Type::Type_Id::string:
61 out <<
"const std::string &";
63 out <<
"std::string_view";
68 #define TYPE_MACRO(storage_tt, return_tt, type_id, read, write)\
69 case Type::Type_Id::type_id:\
70 if (return_type || setter_type)\
75 #define TYPE_MACRO_NO_REFERENCE
76 #define TYPE_MACRO_NO_STRING
90 if (index.field_ids.size() > 1)
94 for (
size_t i = 0; i < index.field_ids.size(); i++)
99 const Type &type = options.db.get_field_type
105 write_type(out, type,
false,
false);
117 options.db.get_field_type(index.table_id, index.field_ids[0]),
128 #define STRINGIFY(X) #X
129 #define EXPAND_AND_STRINGIFY(X) STRINGIFY(X)
135 static constexpr char const *
const types[] =
138 #define TYPE_MACRO(a, b, type_id, d, e) EXPAND_AND_STRINGIFY(type_id),
149 static char const *
const cpp_types[] =
152 #define TYPE_MACRO(a, type, c, d, e) EXPAND_AND_STRINGIFY(type),
163 static char const *
const storage_types[] =
166 #define TYPE_MACRO(storage, b, c, d, e) EXPAND_AND_STRINGIFY(storage),
173 #undef EXPAND_AND_STRINGIFY
180 std::string dir_name,
181 std::string file_name,
184 dir_name(
std::move(dir_name)),
185 file_name(
std::move(file_name)),
194 const std::string dir_string =
const std::string & get_name_space_back() const
const Freedom_Keeper & get_freedom(Table_Id table_id) const override
const std::map< Table_Id, std::string > & get_tables() const override
Record_Id get_used_count() const
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)
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)