0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
clanguml::class_diagram::model Namespace Reference

Classes

class  class_
 Diagram element representing a class or class template. More...
 
class  class_element
 Base class for class elements (e.g. member or method). More...
 
class  class_member
 Class member model. More...
 
class  class_member_base
 Generic class member model. More...
 
class  class_method
 Class method model. More...
 
class  class_method_base
 Class method model. More...
 
class  concept_
 Model of C++ concept. More...
 
class  diagram
 Class representing a class diagram. More...
 
class  enum_
 
class  method_parameter
 Model of a method parameter. More...
 
class  objc_interface
 
class  objc_member
 ObjC class member model. More...
 
class  objc_method
 ObjC class method model. More...
 

Typedefs

using nested_trait_ns = clanguml::common::model::nested_trait< clanguml::common::model::element, clanguml::common::model::namespace_ >
 

Functions

void set_module (nlohmann::json &j, const common::model::element &e)
 
void to_json (nlohmann::json &j, const class_element &c)
 
void to_json (nlohmann::json &j, const class_member &c)
 
void to_json (nlohmann::json &j, const method_parameter &c)
 
void to_json (nlohmann::json &j, const class_method &c)
 
void to_json (nlohmann::json &j, const objc_method &c)
 
void to_json (nlohmann::json &j, const class_ &c)
 
void to_json (nlohmann::json &j, const objc_interface &c)
 
void to_json (nlohmann::json &j, const enum_ &c)
 
void to_json (nlohmann::json &j, const concept_ &c)
 
bool operator== (const class_ &l, const class_ &r)
 
bool operator== (const concept_ &l, const concept_ &r)
 
template<>
bool diagram::add_with_namespace_path< common::model::package > (std::unique_ptr< common::model::package > &&p)
 
template<>
bool diagram::add_with_filesystem_path< common::model::package > (const common::model::path &, std::unique_ptr< common::model::package > &&p)
 
template<>
bool diagram::add_with_module_path< common::model::package > (const common::model::path &, std::unique_ptr< common::model::package > &&p)
 
template<>
bool diagram::add_with_namespace_path< common::model::package > (std::unique_ptr< common::model::package > &&p)
 
template<>
bool diagram::add_with_module_path< common::model::package > (const common::model::path &parent_path, std::unique_ptr< common::model::package > &&p)
 
template<>
bool diagram::add_with_filesystem_path< common::model::package > (const common::model::path &parent_path, std::unique_ptr< common::model::package > &&p)
 
bool operator== (const enum_ &l, const enum_ &r)
 
bool operator== (const objc_interface &l, const objc_interface &r)
 

Typedef Documentation

◆ nested_trait_ns

Definition at line 47 of file diagram.h.

Function Documentation

◆ diagram::add_with_filesystem_path< common::model::package >() [1/2]

Definition at line 135 of file diagram.cc.

138{
139 LOG_DBG("Adding filesystem package: {}, {}", p->name(), p->full_name(true));
140
141 auto ns = p->get_relative_namespace();
142
143 return add_element(ns, std::move(p));
144}

◆ diagram::add_with_filesystem_path< common::model::package >() [2/2]

Definition at line 135 of file diagram.cc.

138{
139 LOG_DBG("Adding filesystem package: {}, {}", p->name(), p->full_name(true));
140
141 auto ns = p->get_relative_namespace();
142
143 return add_element(ns, std::move(p));
144}

◆ diagram::add_with_module_path< common::model::package >() [1/2]

Definition at line 147 of file diagram.cc.

150{
151 LOG_DBG("Adding module package: {}, {}", p->name(), p->full_name(true));
152
153 auto ns = p->get_relative_namespace();
154
155 return add_element(ns, std::move(p));
156}

◆ diagram::add_with_module_path< common::model::package >() [2/2]

Definition at line 147 of file diagram.cc.

150{
151 LOG_DBG("Adding module package: {}, {}", p->name(), p->full_name(true));
152
153 auto ns = p->get_relative_namespace();
154
155 return add_element(ns, std::move(p));
156}

◆ diagram::add_with_namespace_path< common::model::package >() [1/2]

Definition at line 122 of file diagram.cc.

124{
125 LOG_DBG("Adding namespace package: {}, {}", p->name(), p->full_name(true));
126
127 auto ns = p->get_relative_namespace();
128 if (common::model::needs_root_prefix(*p) && p->get_namespace().is_empty())
129 p->is_root(true);
130
131 return add_element(ns, std::move(p));
132}

◆ diagram::add_with_namespace_path< common::model::package >() [2/2]

Definition at line 122 of file diagram.cc.

124{
125 LOG_DBG("Adding namespace package: {}, {}", p->name(), p->full_name(true));
126
127 auto ns = p->get_relative_namespace();
128 if (common::model::needs_root_prefix(*p) && p->get_namespace().is_empty())
129 p->is_root(true);
130
131 return add_element(ns, std::move(p));
132}

◆ operator==() [1/4]

bool clanguml::class_diagram::model::operator== ( const class_ l,
const class_ r 
)

Definition at line 55 of file class.cc.

55{ return l.id() == r.id(); }

◆ operator==() [2/4]

bool clanguml::class_diagram::model::operator== ( const concept_ l,
const concept_ r 
)

Definition at line 31 of file concept.cc.

32{
33 return l.id() == r.id();
34}

◆ operator==() [3/4]

bool clanguml::class_diagram::model::operator== ( const enum_ l,
const enum_ r 
)

Definition at line 32 of file enum.cc.

33{
34 return (l.get_namespace() == r.get_namespace()) && (l.name() == r.name());
35}

◆ operator==() [4/4]

bool clanguml::class_diagram::model::operator== ( const objc_interface l,
const objc_interface r 
)

Definition at line 33 of file objc_interface.cc.

34{
35 return l.id() == r.id();
36}

◆ set_module()

void clanguml::class_diagram::model::set_module ( nlohmann::json &  j,
const common::model::element e 
)

Definition at line 27 of file class_diagram_generator.cc.

28{
29 if (const auto &maybe_module = e.module(); maybe_module) {
30 j["module"]["name"] = *maybe_module;
31 j["module"]["is_private"] = e.module_private();
32 }
33}

◆ to_json() [1/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const class_ c 
)

Definition at line 96 of file class_diagram_generator.cc.

97{
98 j = dynamic_cast<const common::model::element &>(c);
99 j["is_struct"] = c.is_struct();
100 j["is_abstract"] = c.is_abstract();
101 j["is_union"] = c.is_union();
102 j["is_nested"] = c.is_nested();
103 j["is_template"] = c.is_template();
104
105 j["members"] = c.members();
106 j["methods"] = c.methods();
107 auto bases = nlohmann::json::array();
108
109 for (const auto &rel : c.relationships()) {
110 if (rel.type() != common::model::relationship_t::kExtension)
111 continue;
112
113 auto base = nlohmann::json::object();
114 base["is_virtual"] = rel.is_virtual();
115 base["id"] = std::to_string(rel.destination().value());
116 if (rel.access() != common::model::access_t::kNone)
117 base["access"] = to_string(rel.access());
118 bases.push_back(std::move(base));
119 }
120 j["bases"] = std::move(bases);
121
122 set_module(j, c);
123
124 j["template_parameters"] = c.template_params();
125}

◆ to_json() [2/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const class_element c 
)

Definition at line 35 of file class_diagram_generator.cc.

36{
37 j["name"] = display_name_adapter(c).name();
38 j["type"] = display_name_adapter(c).type();
39 if (c.access() != common::model::access_t::kNone)
40 j["access"] = to_string(c.access());
41 if (!c.file().empty())
42 j["source_location"] =
43 dynamic_cast<const common::model::source_location &>(c);
44 if (const auto &comment = c.comment(); comment)
45 j["comment"] = comment.value();
46}

◆ to_json() [3/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const class_member c 
)

Definition at line 48 of file class_diagram_generator.cc.

49{
50 j = dynamic_cast<const class_element &>(c);
51 j["is_static"] = c.is_static();
52}

◆ to_json() [4/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const class_method c 
)

Definition at line 62 of file class_diagram_generator.cc.

63{
64 j = dynamic_cast<const class_element &>(c);
65
66 j["is_pure_virtual"] = c.is_pure_virtual();
67 j["is_virtual"] = c.is_virtual();
68 j["is_const"] = c.is_const();
69 j["is_defaulted"] = c.is_defaulted();
70 j["is_deleted"] = c.is_deleted();
71 j["is_static"] = c.is_static();
72 j["is_noexcept"] = c.is_noexcept();
73 j["is_constexpr"] = c.is_constexpr();
74 j["is_consteval"] = c.is_consteval();
75 j["is_coroutine"] = c.is_coroutine();
76 j["is_constructor"] = c.is_constructor();
77 j["is_move_assignment"] = c.is_move_assignment();
78 j["is_copy_assignment"] = c.is_copy_assignment();
79 j["is_operator"] = c.is_operator();
80 j["template_parameters"] = c.template_params();
81 j["display_name"] = c.display_name();
82
83 j["parameters"] = c.parameters();
84}

◆ to_json() [5/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const concept_ c 
)

Definition at line 165 of file class_diagram_generator.cc.

166{
167 j = dynamic_cast<const common::model::element &>(c);
168 j["parameters"] = c.requires_parameters();
169 j["statements"] = c.requires_statements();
170
171 set_module(j, c);
172}

◆ to_json() [6/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const enum_ c 
)

Definition at line 156 of file class_diagram_generator.cc.

157{
158 j = dynamic_cast<const common::model::element &>(c);
159 j["is_nested"] = c.is_nested();
160 j["constants"] = c.constants();
161
162 set_module(j, c);
163}

◆ to_json() [7/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const method_parameter c 
)

Definition at line 54 of file class_diagram_generator.cc.

55{
56 j["name"] = c.name();
57 j["type"] = c.type();
58 if (!c.default_value().empty())
59 j["default_value"] = c.default_value();
60}

◆ to_json() [8/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const objc_interface c 
)

Definition at line 127 of file class_diagram_generator.cc.

128{
129 j = dynamic_cast<const common::model::element &>(c);
130 j["is_protocol"] = c.is_protocol();
131 j["is_category"] = c.is_category();
132
133 j["members"] = c.members();
134 j["methods"] = c.methods();
135 auto bases = nlohmann::json::array();
136 auto protocols = nlohmann::json::array();
137
138 for (const auto &rel : c.relationships()) {
139 if (rel.type() == common::model::relationship_t::kExtension) {
140 auto base = nlohmann::json::object();
141 base["id"] = std::to_string(rel.destination().value());
142 if (rel.access() != common::model::access_t::kNone)
143 base["access"] = to_string(rel.access());
144 bases.push_back(std::move(base));
145 }
146 else if (rel.type() == common::model::relationship_t::kInstantiation) {
147 auto protocol = nlohmann::json::object();
148 protocol["id"] = std::to_string(rel.destination().value());
149 protocols.push_back(std::move(protocol));
150 }
151 }
152 j["bases"] = std::move(bases);
153 j["protocols"] = std::move(protocols);
154}

◆ to_json() [9/9]

void clanguml::class_diagram::model::to_json ( nlohmann::json &  j,
const objc_method c 
)

Definition at line 86 of file class_diagram_generator.cc.

87{
88 j = dynamic_cast<const class_element &>(c);
89
90 j["is_optional"] = c.is_optional();
91 j["display_name"] = c.display_name();
92
93 j["parameters"] = c.parameters();
94}