diff --git a/src/common/model/diagram_filter.h b/src/common/model/diagram_filter.h index dce99da2..3a02db5b 100644 --- a/src/common/model/diagram_filter.h +++ b/src/common/model/diagram_filter.h @@ -165,9 +165,10 @@ struct subclass_filter : public filter_visitor { }; struct relationship_filter : public filter_visitor { - relationship_filter(filter_t type, std::vector relationships) + relationship_filter( + filter_t type, std::vector relationships) : filter_visitor{type} - , relationships_{relationships} + , relationships_{std::move(relationships)} { } @@ -178,19 +179,16 @@ struct relationship_filter : public filter_visitor { return {}; return std::any_of(relationships_.begin(), relationships_.end(), - [&r](const auto &rel) { - bool res = to_string(r) == rel; - return res; - }); + [&r](const auto &rel) { return r == rel; }); } - std::vector relationships_; + std::vector relationships_; }; struct scope_filter : public filter_visitor { - scope_filter(filter_t type, std::vector scopes) + scope_filter(filter_t type, std::vector scopes) : filter_visitor{type} - , scopes_{scopes} + , scopes_{std::move(scopes)} { } @@ -199,14 +197,11 @@ struct scope_filter : public filter_visitor { if (scopes_.empty()) return {}; - return std::any_of( - scopes_.begin(), scopes_.end(), [&s](const auto &rel) { - bool res = to_string(s) == rel; - return res; - }); + return std::any_of(scopes_.begin(), scopes_.end(), + [&s](const auto &scope) { return s == scope; }); } - std::vector scopes_; + std::vector scopes_; }; struct context_filter : public filter_visitor { diff --git a/src/config/config.cc b/src/config/config.cc index fea6b369..184113d9 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -151,6 +151,7 @@ template <> void append_value(plantuml &l, const plantuml &r) } namespace YAML { +using clanguml::common::model::relationship_t; using clanguml::common::model::scope_t; using clanguml::config::class_diagram; using clanguml::config::config; @@ -464,6 +465,53 @@ template <> struct convert { } }; +// +// config relationship_t decoder +// +template <> struct convert { + static bool decode(const Node &node, relationship_t &rhs) + { + assert(node.Type() == NodeType::Scalar); + + auto relationship_name = node.as(); + if (relationship_name == "extension" || + relationship_name == "inheritance") { + rhs = relationship_t::kExtension; + } + else if (relationship_name == "composition") { + rhs = relationship_t::kComposition; + } + else if (relationship_name == "aggregation") { + rhs = relationship_t::kAggregation; + } + else if (relationship_name == "containment") { + rhs = relationship_t::kContainment; + } + else if (relationship_name == "ownership") { + rhs = relationship_t::kOwnership; + } + else if (relationship_name == "association") { + rhs = relationship_t::kAssociation; + } + else if (relationship_name == "instantiation") { + rhs = relationship_t::kInstantiation; + } + else if (relationship_name == "friendship") { + rhs = relationship_t::kFriendship; + } + else if (relationship_name == "dependency") { + rhs = relationship_t::kDependency; + } + else if (relationship_name == "none") { + rhs = relationship_t::kNone; + } + else + return false; + + return true; + } +}; + // // config Yaml decoder // diff --git a/src/config/config.h b/src/config/config.h index 089c45f5..482a52a4 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -51,16 +51,16 @@ struct filter { std::vector elements; // E.g.: - // - inheritance + // - inheritance/extension // - dependency // - instantiation - std::vector relationships; + std::vector relationships; // E.g.: // - public // - protected // - private - std::vector scopes; + std::vector scopes; std::vector subclasses; diff --git a/tests/t00039/.clang-uml b/tests/t00039/.clang-uml index 39881de4..b81fa27f 100644 --- a/tests/t00039/.clang-uml +++ b/tests/t00039/.clang-uml @@ -12,4 +12,4 @@ diagrams: subclasses: - clanguml::t00039::A relationships: - - extension \ No newline at end of file + - inheritance \ No newline at end of file