0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Classes | Functions
clanguml::common::generators::plantuml Namespace Reference

Classes

class  generator
 Base class for diagram generators. More...
 

Functions

std::string to_plantuml (const relationship &r, const config::diagram &cfg)
 
std::string to_plantuml (access_t scope)
 
std::string to_plantuml (message_t r)
 
template<typename DiagramModel , typename DiagramConfig >
std::ostream & operator<< (std::ostream &os, const generator< DiagramModel, DiagramConfig > &g)
 

Function Documentation

◆ operator<<()

template<typename DiagramModel , typename DiagramConfig >
std::ostream & clanguml::common::generators::plantuml::operator<< ( std::ostream &  os,
const generator< DiagramModel, DiagramConfig > &  g 
)

Definition at line 515 of file generator.h.

517{
518 g.generate(os);
519 return os;
520}

◆ to_plantuml() [1/3]

std::string clanguml::common::generators::plantuml::to_plantuml ( access_t  scope)

Definition at line 69 of file generator.cc.

70{
71 switch (scope) {
72 case access_t::kPublic:
73 return "+";
74 case access_t::kProtected:
75 return "#";
76 case access_t::kPrivate:
77 return "-";
78 default:
79 return "";
80 }
81}

◆ to_plantuml() [2/3]

std::string clanguml::common::generators::plantuml::to_plantuml ( const relationship r,
const config::diagram cfg 
)

Definition at line 22 of file generator.cc.

23{
25
26 std::string style;
27
28 const auto &inline_style = r.style();
29
30 if (inline_style && !inline_style.value().empty()) {
31 if (inline_style && inline_style.value().back() == ']')
32 style = *inline_style;
33 else
34 style = fmt::format("[{}]", inline_style.value());
35 }
36
37 if (style.empty() && cfg.puml) {
38 if (auto config_style = cfg.puml().get_style(r.type());
39 config_style.has_value()) {
40 style = config_style.value();
41 }
42 }
43
44 switch (r.type()) {
45 case relationship_t::kOwnership:
46 case relationship_t::kComposition:
47 return style.empty() ? "*--" : fmt::format("*-{}-", style);
48 case relationship_t::kAggregation:
49 return style.empty() ? "o--" : fmt::format("o-{}-", style);
50 case relationship_t::kContainment:
51 return style.empty() ? "--+" : fmt::format("-{}-+", style);
52 case relationship_t::kAssociation:
53 return style.empty() ? "-->" : fmt::format("-{}->", style);
54 case relationship_t::kInstantiation:
55 return style.empty() ? "..|>" : fmt::format(".{}.|>", style);
56 case relationship_t::kFriendship:
57 return style.empty() ? "<.." : fmt::format("<.{}.", style);
58 case relationship_t::kDependency:
59 return style.empty() ? "..>" : fmt::format(".{}.>", style);
60 case relationship_t::kConstraint:
61 return style.empty() ? "..>" : fmt::format(".{}.>", style);
62 case relationship_t::kAlias:
63 return style.empty() ? ".." : fmt::format(".{}.", style);
64 default:
65 return "";
66 }
67}

◆ to_plantuml() [3/3]

std::string clanguml::common::generators::plantuml::to_plantuml ( message_t  r)

Definition at line 83 of file generator.cc.

84{
85 switch (r) {
86 case message_t::kCall:
87 return "->";
88 case message_t::kReturn:
89 return "-->";
90 default:
91 return "";
92 }
93}