0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
include_diagram
generators
plantuml
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-2024 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
19
#include "
include_diagram_generator.h
"
20
21
#include "
util/error.h
"
22
23
namespace
clanguml::include_diagram::generators::plantuml
{
24
25
generator::generator
(
diagram_config
&config,
diagram_model
&model)
26
:
common_generator
<
diagram_config
,
diagram_model
>{
config
,
model
}
27
{
28
}
29
30
void
generator::generate_relationships
(
31
const
source_file
&f, std::ostream &ostr)
const
32
{
33
if
(!
util::contains
(
m_generated_aliases
, f.
alias
()))
34
return
;
35
36
LOG_DBG
(
"Generating relationships for file {}"
, f.
full_name
(
true
));
37
38
namespace
plantuml_common =
clanguml::common::generators::plantuml
;
39
40
if
(f.
type
() ==
common::model::source_file_t::kDirectory
) {
41
util::for_each
(f, [
this
, &ostr](
const
auto
&file) {
42
generate_relationships
(
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
55
void
generator::generate
(
const
source_file
&f, std::ostream &ostr)
const
56
{
57
if
(f.
type
() ==
common::model::source_file_t::kDirectory
) {
58
LOG_DBG
(
"Generating directory {}"
, f.
name
());
59
60
ostr <<
"folder \""
<< f.
name
();
61
ostr <<
"\" as "
<< f.
alias
();
62
ostr <<
" {\n"
;
63
64
util::for_each
(f, [
this
, &ostr](
const
auto
&file) {
65
generate
(
dynamic_cast<
const
source_file
&
>
(*file), ostr);
66
});
67
68
ostr <<
"}"
<<
'\n'
;
69
70
m_generated_aliases
.emplace(f.
alias
());
71
}
72
else
{
73
LOG_DBG
(
"Generating file {}"
, f.
name
());
74
75
ostr <<
"file \""
<< f.
name
() <<
"\" as "
<< f.
alias
();
76
77
if
(
config
().generate_links) {
78
generate_link
(ostr, f);
79
}
80
81
ostr <<
'\n'
;
82
83
m_generated_aliases
.emplace(f.
alias
());
84
}
85
}
86
87
void
generator::generate_diagram
(std::ostream &ostr)
const
88
{
89
// Generate files and folders
90
util::for_each
(
model
(), [
this
, &ostr](
const
auto
&f) {
91
generate
(
dynamic_cast<
source_file
&
>
(*f), ostr);
92
});
93
94
// Process file include relationships
95
util::for_each
(
model
(), [
this
, &ostr](
const
auto
&f) {
96
generate_relationships
(
dynamic_cast<
source_file
&
>
(*f), ostr);
97
});
98
99
generate_config_layout_hints
(ostr);
100
}
101
}
// namespace clanguml::include_diagram::generators::plantuml
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7