0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
include_diagram_generator.cc
Go to the documentation of this file.
1/**
2 * @file src/include_diagram/generators/plantuml/include_diagram_generator.cc
3 *
4 * Copyright (c) 2021-2025 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
20
21#include "util/error.h"
22
24
27{
28}
29
31 const source_file &f, std::ostream &ostr) const
32{
34 return;
35
36 LOG_DBG("Generating relationships for file {}", f.full_name(true));
37
38 namespace plantuml_common = clanguml::common::generators::plantuml;
39
41 util::for_each(f, [this, &ostr](const auto &file) {
43 dynamic_cast<const source_file &>(*file), ostr);
44 });
45 }
46 else {
47 for (const auto &r : f.relationships()) {
48 ostr << f.alias() << " "
49 << plantuml_common::to_plantuml(r, config()) << " "
50 << model().get(r.destination()).value().alias() << '\n';
51 }
52 }
53}
54
55void generator::generate(const source_file &f, std::ostream &ostr) const
56{
57 if (config().generate_packages && !config().generate_packages()) {
59 }
60 else {
62 }
63}
64
66 const source_file &f, std::ostream &ostr) const
67{
69 LOG_DBG("Generating directory {}", f.name());
70
71 ostr << "folder \"" << f.name();
72 ostr << "\" as " << f.alias();
73 ostr << " {\n";
74
75 util::for_each(f, [this, &ostr](const auto &file) {
76 generate(dynamic_cast<const source_file &>(*file), ostr);
77 });
78
79 ostr << "}" << '\n';
80
81 m_generated_aliases.emplace(f.alias());
82 }
83 else {
84 LOG_DBG("Generating file {}", f.name());
85
86 ostr << "file \"" << f.name() << "\" as " << f.alias();
87
88 if (config().generate_links) {
89 generate_link(ostr, f);
90 }
91
92 ostr << '\n';
93
94 m_generated_aliases.emplace(f.alias());
95 }
96}
97
99 const source_file &f, std::ostream &ostr) const
100{
101 LOG_DBG("Generating file {}", f.name());
102
104 util::for_each(f, [this, &ostr](const auto &file) {
105 generate(dynamic_cast<const source_file &>(*file), ostr);
106 });
107
108 m_generated_aliases.emplace(f.alias());
109 }
110 else {
111 ostr << "file \"" << f.file_relative() << "\" as " << f.alias();
112
113 if (config().generate_links) {
114 generate_link(ostr, f);
115 }
116
117 ostr << '\n';
118
119 m_generated_aliases.emplace(f.alias());
120 }
121}
122
123void generator::generate_diagram(std::ostream &ostr) const
124{
125 // Generate files and folders
126 util::for_each(model(), [this, &ostr](const auto &f) {
127 generate(dynamic_cast<source_file &>(*f), ostr);
128 });
129
130 // Process file include relationships
131 util::for_each(model(), [this, &ostr](const auto &f) {
132 generate_relationships(dynamic_cast<source_file &>(*f), ostr);
133 });
134
136}
137} // namespace clanguml::include_diagram::generators::plantuml