ores.cpp.repository.entity_impl
Out-of-class implementations for the sqlgen entity. repository profile.
See the Template variable reference for the complete list of available variables and their semantics.
Template
The full template source. Edit here and re-tangle with
compass build --direct tangle_codegen_templates to regenerate
library/templates/cpp_domain_type_entity.cpp.mustache.
The generated file's only job is to give the sqlgen entity struct a
std::ostream operator<< — the entity itself is a plain aggregate
with no out-of-class members, so this is the entire .cpp. It's a
thin wrapper over rfl::json::write: printing an entity as JSON is
more useful for debugging (logs, test failure output) than a
hand-rolled field dump would be, and it comes for free once the
struct is rfl-reflectable.
The model has exactly two shapes that reach this template —
domain_entity (a regular entity, keyed by entity_singular) and
junction (a many-to-many link table, keyed by name_singular) —
and they never co-occur for the same generated file, so the two
mustache sections below are alternatives, not a sequence: exactly
one of the two blocks below is emitted per generation run,
distinguished only by the field name the operator is written against.
{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cpp_repository.org. Edit the org source. }}
{{{cpp_license}}}
{{#domain_entity}}
#include "ores.{{component_core}}/repository/{{entity_singular}}_entity.hpp"
#include "ores.utility/rfl/reflectors.hpp" // IWYU pragma: keep.
#include <ostream>
#include <rfl.hpp>
#include <rfl/json.hpp>
namespace ores::{{component}}::repository {
std::ostream& operator<<(std::ostream& s, const {{entity_singular}}_entity& v) {
rfl::json::write(v, s);
return s;
}
}
{{/domain_entity}}
The junction case is the same operator, generated against the
junction's own entity struct (name_singular) instead of a regular
entity's (entity_singular) — the only difference between the two
branches.
{{#junction}}
#include "ores.{{component_core}}/repository/{{name_singular}}_entity.hpp"
#include "ores.utility/rfl/reflectors.hpp" // IWYU pragma: keep.
#include <ostream>
#include <rfl.hpp>
#include <rfl/json.hpp>
namespace ores::{{component}}::repository {
std::ostream& operator<<(std::ostream& s, const {{name_singular}}_entity& v) {
rfl::json::write(v, s);
return s;
}
}
{{/junction}}
See also
- Parent facet: ores.cpp.repository
- Template variable reference