0.6.1
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
common
model
enums.cc
Go to the documentation of this file.
1
/**
2
* @file src/common/model/enums.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
#include "
enums.h
"
19
20
#include <cassert>
21
#include <stdexcept>
22
23
namespace
clanguml::common::model
{
24
25
bool
is_return
(
message_t
t)
26
{
27
return
t ==
message_t::kReturn
|| t ==
message_t::kCoReturn
||
28
t ==
message_t::kCoYield
;
29
}
30
31
std::string
to_string
(
relationship_t
r)
32
{
33
switch
(r) {
34
case
relationship_t::kNone
:
35
return
"none"
;
36
case
relationship_t::kExtension
:
37
return
"extension"
;
38
case
relationship_t::kComposition
:
39
return
"composition"
;
40
case
relationship_t::kAggregation
:
41
return
"aggregation"
;
42
case
relationship_t::kContainment
:
43
return
"containment"
;
44
case
relationship_t::kOwnership
:
45
return
"ownership"
;
46
case
relationship_t::kAssociation
:
47
return
"association"
;
48
case
relationship_t::kInstantiation
:
49
return
"instantiation"
;
50
case
relationship_t::kFriendship
:
51
return
"friendship"
;
52
case
relationship_t::kDependency
:
53
return
"dependency"
;
54
case
relationship_t::kAlias
:
55
return
"alias"
;
56
case
relationship_t::kConstraint
:
57
return
"constraint"
;
58
default
:
59
assert(
false
);
60
return
""
;
61
}
62
}
63
64
std::string
to_string
(
access_t
a)
65
{
66
switch
(a) {
67
case
access_t::kPublic
:
68
return
"public"
;
69
case
access_t::kProtected
:
70
return
"protected"
;
71
case
access_t::kPrivate
:
72
return
"private"
;
73
case
access_t::kNone
:
74
return
"none"
;
75
default
:
76
assert(
false
);
77
return
""
;
78
}
79
}
80
81
std::string
to_string
(
module_access_t
a)
82
{
83
switch
(a) {
84
case
module_access_t::kPublic
:
85
return
"public"
;
86
case
module_access_t::kPrivate
:
87
return
"private"
;
88
default
:
89
assert(
false
);
90
return
""
;
91
}
92
}
93
94
std::string
to_string
(
message_t
r)
95
{
96
switch
(r) {
97
case
message_t::kCall
:
98
return
"call"
;
99
case
message_t::kReturn
:
100
return
"return"
;
101
case
message_t::kIf
:
102
return
"if"
;
103
case
message_t::kElse
:
104
return
"else"
;
105
case
message_t::kElseIf
:
106
return
"else if"
;
107
case
message_t::kIfEnd
:
108
return
"end if"
;
109
case
message_t::kWhile
:
110
return
"while"
;
111
case
message_t::kWhileEnd
:
112
return
"end while"
;
113
case
message_t::kDo
:
114
return
"do"
;
115
case
message_t::kDoEnd
:
116
return
"end do"
;
117
case
message_t::kFor
:
118
return
"for"
;
119
case
message_t::kForEnd
:
120
return
"end for"
;
121
case
message_t::kTry
:
122
return
"try"
;
123
case
message_t::kCatch
:
124
return
"catch"
;
125
case
message_t::kTryEnd
:
126
return
"end try"
;
127
case
message_t::kSwitch
:
128
return
"switch"
;
129
case
message_t::kCase
:
130
return
"case"
;
131
case
message_t::kSwitchEnd
:
132
return
"end switch"
;
133
case
message_t::kConditional
:
134
return
"conditional"
;
135
case
message_t::kConditionalElse
:
136
return
"conditional else"
;
137
case
message_t::kConditionalEnd
:
138
return
"end conditional"
;
139
case
message_t::kCoReturn
:
140
return
"co_return"
;
141
case
message_t::kCoYield
:
142
return
"co_yield"
;
143
case
message_t::kCoAwait
:
144
return
"co_await"
;
145
default
:
146
assert(
false
);
147
return
""
;
148
}
149
}
150
151
std::string
to_string
(
const
diagram_t
t)
152
{
153
switch
(t) {
154
case
diagram_t::kClass
:
155
return
"class"
;
156
case
diagram_t::kSequence
:
157
return
"sequence"
;
158
case
diagram_t::kPackage
:
159
return
"package"
;
160
case
diagram_t::kInclude
:
161
return
"include"
;
162
default
:
163
assert(
false
);
164
return
""
;
165
}
166
}
167
168
std::string
to_string
(
const
message_scope_t
t)
169
{
170
switch
(t) {
171
case
message_scope_t::kNormal
:
172
return
"normal"
;
173
case
message_scope_t::kCondition
:
174
return
"condition"
;
175
default
:
176
assert(
false
);
177
return
""
;
178
}
179
}
180
181
diagram_t
from_string
(
const
std::string &s)
182
{
183
if
(s ==
"class"
)
184
return
diagram_t::kClass
;
185
if
(s ==
"sequence"
)
186
return
diagram_t::kSequence
;
187
if
(s ==
"include"
)
188
return
diagram_t::kInclude
;
189
if
(s ==
"package"
)
190
return
diagram_t::kPackage
;
191
192
throw
std::runtime_error{
"Invalid diagram type: "
+ s};
193
}
194
195
}
// namespace clanguml::common::model
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7