0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
enum.cc
Go to the documentation of this file.
1/**
2 * @file src/class_diagram/model/enum.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 "enum.h"
20
21#include "util/util.h"
22
23#include <sstream>
24
26
28 : element{using_namespace}
29{
30}
31
32bool operator==(const enum_ &l, const enum_ &r)
33{
34 return (l.get_namespace() == r.get_namespace()) && (l.name() == r.name());
35}
36
37std::string enum_::full_name(bool relative) const
38{
39 using namespace clanguml::util;
41
42 std::ostringstream ostr;
43 if (relative)
44 ostr << namespace_{name_and_ns()}
45 .relative_to(using_namespace())
46 .to_string();
47 else
48 ostr << name_and_ns();
49
50 return ostr.str();
51}
52
53std::vector<std::string> &enum_::constants() { return constants_; }
54
55const std::vector<std::string> &enum_::constants() const { return constants_; }
56
57std::optional<std::string> enum_::doxygen_link() const
58{
59 auto name = name_and_ns();
60 util::replace_all(name, "_", "__");
61 util::replace_all(name, "::", "_1_1");
62 return fmt::format("enum{}.html", name);
63}
64} // namespace clanguml::class_diagram::model