0.5.6
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Classes | Functions
YAML Namespace Reference

Classes

struct  convert< access_t >
 
struct  convert< callee_type >
 
struct  convert< class_diagram >
 
struct  convert< config >
 
struct  convert< context_config >
 
struct  convert< context_direction_t >
 
struct  convert< diagram_template >
 
struct  convert< element_filter_t >
 
struct  convert< filter >
 
struct  convert< generate_links_config >
 
struct  convert< git_config >
 
struct  convert< include_diagram >
 
struct  convert< layout_hint >
 
struct  convert< mermaid >
 
struct  convert< method_type >
 
struct  convert< module_access_t >
 
struct  convert< namespace_or_regex >
 
struct  convert< package_diagram >
 
struct  convert< plantuml >
 
struct  convert< relationship_hint_t >
 
struct  convert< relationship_t >
 
struct  convert< sequence_diagram >
 
struct  convert< std::filesystem::path >
 
struct  convert< std::vector< source_location > >
 
struct  convert< string_or_regex >
 

Functions

bool has_key (const YAML::Node &n, const std::string &key)
 
template<typename T >
void get_option (const Node &node, clanguml::config::option< T > &option)
 
template<>
void get_option< clanguml::common::model::namespace_ > (const Node &node, clanguml::config::option< clanguml::common::model::namespace_ > &option)
 
template<>
void get_option< method_arguments > (const Node &node, clanguml::config::option< method_arguments > &option)
 
template<>
void get_option< member_order_t > (const Node &node, clanguml::config::option< member_order_t > &option)
 
template<>
void get_option< package_type_t > (const Node &node, clanguml::config::option< package_type_t > &option)
 
template<>
void get_option< clanguml::config::comment_parser_t > (const Node &node, clanguml::config::option< clanguml::config::comment_parser_t > &option)
 
template<>
void get_option< clanguml::config::filter_mode_t > (const Node &node, clanguml::config::option< clanguml::config::filter_mode_t > &option)
 
template<>
void get_option< std::map< std::string, clanguml::config::diagram_template > > (const Node &node, clanguml::config::option< std::map< std::string, clanguml::config::diagram_template > > &option)
 
std::shared_ptr< clanguml::config::diagramparse_diagram_config (const Node &d)
 
template<typename T >
bool decode_diagram (const Node &node, T &rhs)
 

Function Documentation

◆ decode_diagram()

template<typename T >
bool YAML::decode_diagram ( const Node &  node,
T &  rhs 
)

Definition at line 720 of file yaml_decoders.cc.

721{
722 // Decode options common for all diagrams
723 get_option(node, rhs.glob);
724 get_option(node, rhs.using_namespace);
725 get_option(node, rhs.using_module);
726 get_option(node, rhs.filter_mode);
727 get_option(node, rhs.include_system_headers);
728 get_option(node, rhs.include);
729 get_option(node, rhs.exclude);
730 get_option(node, rhs.puml);
731 get_option(node, rhs.mermaid);
732 get_option(node, rhs.git);
733 get_option(node, rhs.generate_links);
734 get_option(node, rhs.type_aliases);
735 get_option(node, rhs.comment_parser);
736 get_option(node, rhs.debug_mode);
737 get_option(node, rhs.generate_metadata);
738 get_option(node, rhs.title);
739 get_option(node, rhs.get_relative_to());
740
741 return true;
742}

◆ get_option()

template<typename T >
void YAML::get_option ( const Node &  node,
clanguml::config::option< T > &  option 
)

Definition at line 69 of file yaml_decoders.cc.

70{
71 if (node[option.name])
72 option.set(node[option.name].template as<T>());
73
74 for (const auto &alt_name : option.alternate_names)
75 if (node[alt_name]) {
76 option.set(node[alt_name].template as<T>());
77 break;
78 }
79}

◆ get_option< clanguml::common::model::namespace_ >()

Definition at line 82 of file yaml_decoders.cc.

84{
85 if (node[option.name]) {
86 if (node[option.name].Type() == NodeType::Scalar)
87 option.set({node[option.name].template as<std::string>()});
88 else if (node[option.name].Type() == NodeType::Sequence)
89 option.set(
90 {node[option.name].template as<std::vector<std::string>>()[0]});
91 else
92 throw std::runtime_error("Invalid using_namespace value");
93 }
94}

◆ get_option< clanguml::config::comment_parser_t >()

Definition at line 148 of file yaml_decoders.cc.

150{
151 if (node[option.name]) {
152 const auto &val = node[option.name].as<std::string>();
153 if (val == "plain")
155 else if (val == "clang")
157 else
158 throw std::runtime_error("Invalid comment_parser value: " + val);
159 }
160}

◆ get_option< clanguml::config::filter_mode_t >()

Definition at line 163 of file yaml_decoders.cc.

165{
166 if (node[option.name]) {
167 const auto &val = node[option.name].as<std::string>();
168 if (val == "basic")
170 else if (val == "advanced")
172 else
173 throw std::runtime_error("Invalid comment_parser value: " + val);
174 }
175}

◆ get_option< member_order_t >()

template<>
void YAML::get_option< member_order_t > ( const Node &  node,
clanguml::config::option< member_order_t > &  option 
)

Definition at line 115 of file yaml_decoders.cc.

117{
118 if (node[option.name]) {
119 const auto &val = node[option.name].as<std::string>();
120 if (val == "as_is")
121 option.set(member_order_t::as_is);
122 else if (val == "lexical")
123 option.set(member_order_t::lexical);
124 else
125 throw std::runtime_error("Invalid member_order value: " + val);
126 }
127}

◆ get_option< method_arguments >()

template<>
void YAML::get_option< method_arguments > ( const Node &  node,
clanguml::config::option< method_arguments > &  option 
)

Definition at line 97 of file yaml_decoders.cc.

99{
100 if (node[option.name]) {
101 const auto &val = node[option.name].as<std::string>();
102 if (val == "full")
103 option.set(method_arguments::full);
104 else if (val == "abbreviated")
105 option.set(method_arguments::abbreviated);
106 else if (val == "none")
107 option.set(method_arguments::none);
108 else
109 throw std::runtime_error(
110 "Invalid generate_method_arguments value: " + val);
111 }
112}

◆ get_option< package_type_t >()

template<>
void YAML::get_option< package_type_t > ( const Node &  node,
clanguml::config::option< package_type_t > &  option 
)

Definition at line 130 of file yaml_decoders.cc.

132{
133 if (node[option.name]) {
134 const auto &val = node[option.name].as<std::string>();
135 if (val == "namespace")
136 option.set(package_type_t::kNamespace);
137 else if (val == "directory")
138 option.set(package_type_t::kDirectory);
139 else if (val == "module")
140 option.set(package_type_t::kModule);
141 else
142 throw std::runtime_error(
143 "Invalid generate_method_arguments value: " + val);
144 }
145}

◆ get_option< std::map< std::string, clanguml::config::diagram_template > >()

template<>
void YAML::get_option< std::map< std::string, clanguml::config::diagram_template > > ( const Node &  node,
clanguml::config::option< std::map< std::string, clanguml::config::diagram_template > > &  option 
)

Definition at line 178 of file yaml_decoders.cc.

182{
183 if (!node[option.name]) {
184 return;
185 }
186
187 if (node[option.name].IsMap() && node[option.name]["include!"]) {
188 auto parent_path = node["__parent_path"].as<std::string>();
189
190 // Load templates from file
191 auto include_path = std::filesystem::path{parent_path};
192 include_path /= node[option.name]["include!"].as<std::string>();
193
194 YAML::Node included_node = YAML::LoadFile(include_path.string());
195
196 option.set(
197 included_node.as<
198 std::map<std::string, clanguml::config::diagram_template>>());
199 }
200 else
201 option.set(node[option.name]
202 .as<std::map<std::string,
204}

◆ has_key()

bool YAML::has_key ( const YAML::Node &  n,
const std::string &  key 
)
inline

Definition at line 59 of file yaml_decoders.cc.

60{
61 assert(n.Type() == NodeType::Map);
62
63 return std::count_if(n.begin(), n.end(), [&key](auto &&n) {
64 return n.first.template as<std::string>() == key;
65 }) > 0;
66}

◆ parse_diagram_config()

std::shared_ptr< clanguml::config::diagram > YAML::parse_diagram_config ( const Node &  d)

Definition at line 206 of file yaml_decoders.cc.

207{
208 const auto diagram_type = d["type"].as<std::string>();
209
210 if (diagram_type == "class") {
211 return std::make_shared<class_diagram>(d.as<class_diagram>());
212 }
213 if (diagram_type == "sequence") {
214 return std::make_shared<sequence_diagram>(d.as<sequence_diagram>());
215 }
216 if (diagram_type == "package") {
217 return std::make_shared<package_diagram>(d.as<package_diagram>());
218 }
219 if (diagram_type == "include") {
220 return std::make_shared<include_diagram>(d.as<include_diagram>());
221 }
222
223 LOG_ERROR("Diagrams of type {} are not supported... ", diagram_type);
224
225 return {};
226}