0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
common
generators
graphml
generator.cc
Go to the documentation of this file.
1
/**
2
* @file src/common/generators/json/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
19
#include "
generator.h
"
20
21
namespace
clanguml::common::generators::graphml
{
22
23
std::string
to_string
(
const
property_type
t)
24
{
25
switch
(t) {
26
case
property_type::kBoolean
:
27
return
"boolean"
;
28
case
property_type::kInt
:
29
return
"int"
;
30
case
property_type::kLong
:
31
return
"long"
;
32
case
property_type::kFloat
:
33
return
"float"
;
34
case
property_type::kDouble
:
35
return
"double"
;
36
case
property_type::kString
:
37
return
"string"
;
38
default
:
39
assert(
false
);
40
return
""
;
41
}
42
}
43
44
property_keymap_t::property_keymap_t
(std::string prefix)
45
: prefix_{
std
::move(prefix)}
46
{
47
}
48
49
[[maybe_unused]] std::pair<std::string, property_type>
property_keymap_t::add
(
50
const
std::string &name,
const
property_type
pt)
51
{
52
map_
[name] = {fmt::format(
"{}{}"
,
prefix_
,
next_data_key_id_
++), pt};
53
return
map_
[name];
54
}
55
56
auto
property_keymap_t::get
(
const
std::string &name)
const
57
-> std::optional<std::pair<std::string, property_type>>
58
{
59
if
(map_.count(name) == 0)
60
return
{};
61
62
return
map_.at(name);
63
}
64
65
graphml_node_map_t::graphml_node_map_t
(std::string prefix)
66
: prefix_{
std
::move(prefix)}
67
{
68
}
69
70
[[maybe_unused]] std::string
graphml_node_map_t::add
(
const
std::string &name)
71
{
72
map_
[name] = fmt::format(
"{}{}"
,
prefix_
,
next_node_id_
++);
73
return
map_
[name];
74
}
75
76
std::optional<std::string>
graphml_node_map_t::get
(
77
const
std::string &name)
const
78
{
79
if
(
map_
.count(name) == 0)
80
return
{};
81
82
return
map_
.at(name);
83
}
84
85
}
// namespace clanguml::common::generators::graphml
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7