29 if (
const auto &maybe_module = e.
module(); maybe_module) {
30 j[
"module"][
"name"] = *maybe_module;
40 j[
"access"] = to_string(c.
access());
41 if (!c.
file().empty())
42 j[
"source_location"] =
44 if (
const auto &comment = c.
comment(); comment)
45 j[
"comment"] = comment.value();
107 auto bases = nlohmann::json::array();
113 auto base = nlohmann::json::object();
114 base[
"is_virtual"] = rel.is_virtual();
115 base[
"id"] = std::to_string(rel.destination().value());
117 base[
"access"] = to_string(rel.access());
118 bases.push_back(std::move(base));
120 j[
"bases"] = std::move(bases);
135 auto bases = nlohmann::json::array();
136 auto protocols = nlohmann::json::array();
140 auto base = nlohmann::json::object();
141 base[
"id"] = std::to_string(rel.destination().value());
143 base[
"access"] = to_string(rel.access());
144 bases.push_back(std::move(base));
147 auto protocol = nlohmann::json::object();
148 protocol[
"id"] = std::to_string(rel.destination().value());
149 protocols.push_back(std::move(protocol));
152 j[
"bases"] = std::move(bases);
153 j[
"protocols"] = std::move(protocols);
186 if (
config().using_namespace)
187 parent[
"using_namespace"] =
config().using_namespace().to_string();
189 if (
config().using_module)
190 parent[
"using_module"] =
config().using_module();
192 if (
config().generate_packages.has_value)
193 parent[
"package_type"] = to_string(
config().package_type());
194 parent[
"elements"] = std::vector<nlohmann::json>{};
195 parent[
"relationships"] = std::vector<nlohmann::json>{};
204 for (
const auto &p :
model()) {
205 if (
auto *pkg =
dynamic_cast<package *
>(p.get()); pkg) {
206 if (!pkg->is_empty())
210 model().dynamic_apply(
211 p.get(), [&](
auto *el) { generate(*el, parent); });
218 const auto &uns =
config().using_namespace();
220 nlohmann::json package_object;
222 if (
config().generate_packages()) {
225 if (!uns.starts_with({p.full_name(false)})) {
228 package_object[
"type"] = to_string(
config().package_type());
229 package_object[
"name"] = p.
name();
230 package_object[
"display_name"] =
235 for (
const auto &subpackage : p) {
236 if (
dynamic_cast<package *
>(subpackage.get()) !=
nullptr) {
237 const auto &sp =
dynamic_cast<package &
>(*subpackage);
238 if (!sp.is_empty()) {
239 if (
config().generate_packages())
246 model().dynamic_apply(subpackage.get(), [&](
auto *el) {
247 if (config().generate_packages())
248 generate(*el, package_object);
250 generate(*el, parent);
255 if (
config().generate_packages() && !package_object.empty()) {
256 parent[
"elements"].push_back(std::move(package_object));
262 nlohmann::json
object = c;
265 if (!
config().generate_fully_qualified_name())
266 object[
"display_name"] =
269 object[
"display_name"] =
270 config().simplify_template_type(
object[
"display_name"]);
272 for (
auto &tp :
object[
"template_parameters"]) {
273 if (tp.contains(
"type") && tp.at(
"type").is_string()) {
274 tp[
"type"] =
config().using_namespace().relative(tp.at(
"type"));
277 for (
auto &tp :
object[
"members"]) {
278 if (tp.contains(
"type") && tp.at(
"type").is_string()) {
279 tp[
"type"] =
config().using_namespace().relative(tp.at(
"type"));
283 parent[
"elements"].push_back(std::move(
object));
288 nlohmann::json
object = e;
290 if (!
config().generate_fully_qualified_name())
293 parent[
"elements"].push_back(std::move(
object));
298 nlohmann::json
object = c;
300 if (!
config().generate_fully_qualified_name())
303 parent[
"elements"].push_back(std::move(
object));
308 nlohmann::json
object = c;
311 if (!
config().generate_fully_qualified_name())
314 object[
"display_name"] =
315 config().simplify_template_type(
object[
"display_name"]);
317 parent[
"elements"].push_back(std::move(
object));
322 for (
const auto &p :
model()) {
323 if (
auto *pkg =
dynamic_cast<package *
>(p.get()); pkg) {
327 model().dynamic_apply(p.get(),
328 [&](
auto *el) { generate_relationships(*el, parent); });
334void generator::generate_relationships<package>(
335 const package &p, nlohmann::json &parent)
const
337 for (
const auto &subpackage : p) {
338 if (
dynamic_cast<package *
>(subpackage.get()) !=
nullptr) {
339 const auto &sp =
dynamic_cast<package &
>(*subpackage);
344 model().dynamic_apply(subpackage.get(), [&](
auto *el) {
345 if (model().should_include(*el)) {
346 generate_relationships(*el, parent);