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