0.6.0
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< glob_t >
 
struct  convert< graphml >
 
struct  convert< include_diagram >
 
struct  convert< inja::json >
 
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

std::shared_ptr< clanguml::config::diagramparse_diagram_config (const YAML::Node &d)
 
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<typename T >
void get_option (const Node &node, clanguml::config::option< T > &option, T default_override)
 
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 787 of file yaml_decoders.cc.

788{
789 // Decode options common for all diagrams
790 get_option(node, rhs.glob);
791 get_option(node, rhs.using_namespace);
792 get_option(node, rhs.using_module);
793 get_option(node, rhs.filter_mode);
794 get_option(node, rhs.include_system_headers);
795 get_option(node, rhs.include);
796 get_option(node, rhs.exclude);
797 get_option(node, rhs.puml);
798 get_option(node, rhs.mermaid);
799 get_option(node, rhs.graphml);
800 get_option(node, rhs.git);
801 get_option(node, rhs.generate_links);
802 get_option(node, rhs.type_aliases);
803 get_option(node, rhs.comment_parser);
804 get_option(node, rhs.debug_mode);
805 get_option(node, rhs.generate_metadata);
806 get_option(node, rhs.title);
807 get_option(node, rhs.get_relative_to());
808 get_option(node, rhs.user_data);
809
810 return true;
811}

◆ get_option() [1/2]

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

Definition at line 116 of file yaml_decoders.cc.

117{
118 if (node[option.name])
119 option.set(node[option.name].template as<T>());
120
121 for (const auto &alt_name : option.alternate_names)
122 if (node[alt_name]) {
123 option.set(node[alt_name].template as<T>());
124 break;
125 }
126}

◆ get_option() [2/2]

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

Definition at line 129 of file yaml_decoders.cc.

131{
132 get_option(node, option);
133
134 if (!option.is_declared)
135 option.set(default_override);
136}

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

Definition at line 139 of file yaml_decoders.cc.

141{
142 if (node[option.name]) {
143 if (node[option.name].Type() == NodeType::Scalar)
144 option.set({node[option.name].template as<std::string>()});
145 else if (node[option.name].Type() == NodeType::Sequence)
146 option.set(
147 {node[option.name].template as<std::vector<std::string>>()[0]});
148 else
149 throw std::runtime_error("Invalid using_namespace value");
150 }
151}

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

Definition at line 205 of file yaml_decoders.cc.

207{
208 if (node[option.name]) {
209 const auto &val = node[option.name].as<std::string>();
210 if (val == "plain")
212 else if (val == "clang")
214 else
215 throw std::runtime_error("Invalid comment_parser value: " + val);
216 }
217}

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

Definition at line 220 of file yaml_decoders.cc.

222{
223 if (node[option.name]) {
224 const auto &val = node[option.name].as<std::string>();
225 if (val == "basic")
227 else if (val == "advanced")
229 else
230 throw std::runtime_error("Invalid comment_parser value: " + val);
231 }
232}

◆ 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 172 of file yaml_decoders.cc.

174{
175 if (node[option.name]) {
176 const auto &val = node[option.name].as<std::string>();
177 if (val == "as_is")
178 option.set(member_order_t::as_is);
179 else if (val == "lexical")
180 option.set(member_order_t::lexical);
181 else
182 throw std::runtime_error("Invalid member_order value: " + val);
183 }
184}

◆ get_option< method_arguments >()

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

Definition at line 154 of file yaml_decoders.cc.

156{
157 if (node[option.name]) {
158 const auto &val = node[option.name].as<std::string>();
159 if (val == "full")
160 option.set(method_arguments::full);
161 else if (val == "abbreviated")
162 option.set(method_arguments::abbreviated);
163 else if (val == "none")
164 option.set(method_arguments::none);
165 else
166 throw std::runtime_error(
167 "Invalid generate_method_arguments value: " + val);
168 }
169}

◆ 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 187 of file yaml_decoders.cc.

189{
190 if (node[option.name]) {
191 const auto &val = node[option.name].as<std::string>();
192 if (val == "namespace")
193 option.set(package_type_t::kNamespace);
194 else if (val == "directory")
195 option.set(package_type_t::kDirectory);
196 else if (val == "module")
197 option.set(package_type_t::kModule);
198 else
199 throw std::runtime_error(
200 "Invalid generate_method_arguments value: " + val);
201 }
202}

◆ 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 235 of file yaml_decoders.cc.

239{
240 if (!node[option.name]) {
241 return;
242 }
243
244 if (node[option.name].IsMap() && node[option.name]["include!"]) {
245 auto parent_path = node["__parent_path"].as<std::string>();
246
247 // Load templates from file
248 auto include_path = std::filesystem::path{parent_path};
249 include_path /= node[option.name]["include!"].as<std::string>();
250
251 YAML::Node included_node = YAML::LoadFile(include_path.string());
252
253 option.set(
254 included_node.as<
255 std::map<std::string, clanguml::config::diagram_template>>());
256 }
257 else
258 option.set(node[option.name]
259 .as<std::map<std::string,
261}

◆ has_key()

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

Definition at line 106 of file yaml_decoders.cc.

107{
108 assert(n.Type() == NodeType::Map);
109
110 return std::count_if(n.begin(), n.end(), [&key](auto &&n) {
111 return n.first.template as<std::string>() == key;
112 }) > 0;
113}

◆ parse_diagram_config() [1/2]

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

Definition at line 263 of file yaml_decoders.cc.

264{
265 const auto diagram_type = d["type"].as<std::string>();
266
267 if (diagram_type == "class") {
268 return std::make_shared<class_diagram>(d.as<class_diagram>());
269 }
270 if (diagram_type == "sequence") {
271 return std::make_shared<sequence_diagram>(d.as<sequence_diagram>());
272 }
273 if (diagram_type == "package") {
274 return std::make_shared<package_diagram>(d.as<package_diagram>());
275 }
276 if (diagram_type == "include") {
277 return std::make_shared<include_diagram>(d.as<include_diagram>());
278 }
279
280 LOG_ERROR("Diagrams of type {} are not supported... ", diagram_type);
281
282 return {};
283}

◆ parse_diagram_config() [2/2]

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