Added style decorators
This commit is contained in:
@@ -54,6 +54,10 @@ enum class relationship_t {
|
||||
|
||||
std::string to_string(relationship_t r);
|
||||
|
||||
struct stylable_element {
|
||||
std::string style;
|
||||
};
|
||||
|
||||
struct decorated_element {
|
||||
std::vector<std::shared_ptr<decorators::decorator>> decorators;
|
||||
|
||||
@@ -93,6 +97,15 @@ struct decorated_element {
|
||||
|
||||
return {relationship_t::kNone, ""};
|
||||
}
|
||||
|
||||
std::string style_spec()
|
||||
{
|
||||
for (auto d : decorators)
|
||||
if (std::dynamic_pointer_cast<decorators::style>(d))
|
||||
return std::dynamic_pointer_cast<decorators::style>(d)->spec;
|
||||
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
class element : public decorated_element {
|
||||
@@ -157,7 +170,7 @@ struct class_parent {
|
||||
access_t access;
|
||||
};
|
||||
|
||||
struct class_relationship : public decorated_element {
|
||||
struct class_relationship : public decorated_element, public stylable_element {
|
||||
relationship_t type{relationship_t::kAssociation};
|
||||
std::string destination;
|
||||
std::string multiplicity_source;
|
||||
@@ -190,7 +203,7 @@ struct type_alias {
|
||||
std::string underlying_type;
|
||||
};
|
||||
|
||||
class class_ : public element {
|
||||
class class_ : public element, public stylable_element {
|
||||
public:
|
||||
std::string usr;
|
||||
bool is_struct{false};
|
||||
@@ -275,7 +288,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct enum_ : public element {
|
||||
struct enum_ : public element, public stylable_element {
|
||||
std::vector<std::string> constants;
|
||||
std::vector<class_relationship> relationships;
|
||||
|
||||
|
||||
@@ -199,6 +199,8 @@ void tu_visitor::process_enum_declaration(const cppast::cpp_enum &enm)
|
||||
if (e.skip())
|
||||
return;
|
||||
|
||||
e.style = e.style_spec();
|
||||
|
||||
// Process enum documentation comment
|
||||
if (enm.comment().has_value())
|
||||
e.decorators = decorators::parse(enm.comment().value());
|
||||
@@ -239,9 +241,6 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
|
||||
if (cls.comment().has_value())
|
||||
c.decorators = decorators::parse(cls.comment().value());
|
||||
|
||||
if (c.skip())
|
||||
return;
|
||||
|
||||
cppast::cpp_access_specifier_kind last_access_specifier =
|
||||
cppast::cpp_access_specifier_kind::cpp_private;
|
||||
|
||||
@@ -256,6 +255,11 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
|
||||
c.decorators = decorators::parse(cls.comment().value());
|
||||
}
|
||||
|
||||
if (c.skip())
|
||||
return;
|
||||
|
||||
c.style = c.style_spec();
|
||||
|
||||
// Process class child entities
|
||||
if (c.is_struct)
|
||||
last_access_specifier = cppast::cpp_access_specifier_kind::cpp_public;
|
||||
@@ -515,7 +519,7 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
|
||||
|
||||
bool tu_visitor::process_field_with_template_instantiation(
|
||||
const cppast::cpp_member_variable &mv, const cppast::cpp_type &tr,
|
||||
class_ &c, cppast::cpp_access_specifier_kind as)
|
||||
class_ &c, class_member &m, cppast::cpp_access_specifier_kind as)
|
||||
{
|
||||
LOG_DBG("Processing field with template instatiation type {}",
|
||||
cppast::to_string(tr));
|
||||
@@ -572,6 +576,17 @@ bool tu_visitor::process_field_with_template_instantiation(
|
||||
rr.type = relationship_t::kAggregation;
|
||||
rr.label = mv.name();
|
||||
rr.scope = detail::cpp_access_specifier_to_scope(as);
|
||||
rr.style = m.style_spec();
|
||||
|
||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
||||
if (decorator_rtype != relationship_t::kNone) {
|
||||
rr.type = decorator_rtype;
|
||||
auto mult = util::split(decorator_rmult, ":");
|
||||
if (mult.size() == 2) {
|
||||
rr.multiplicity_source = mult[0];
|
||||
rr.multiplicity_destination = mult[1];
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
||||
rr.destination, model::class_diagram::to_string(rr.type), c.usr,
|
||||
@@ -623,7 +638,7 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c,
|
||||
else if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) {
|
||||
template_instantiation_added_as_aggregation =
|
||||
process_field_with_template_instantiation(
|
||||
mv, resolve_alias(tr), c, as);
|
||||
mv, resolve_alias(tr), c, m, as);
|
||||
}
|
||||
else if (tr.kind() == cppast::cpp_type_kind::unexposed_t) {
|
||||
LOG_DBG(
|
||||
@@ -646,6 +661,7 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c,
|
||||
r.type = relationship_type;
|
||||
r.label = m.name;
|
||||
r.scope = m.scope;
|
||||
r.style = m.style_spec();
|
||||
|
||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
||||
if (decorator_rtype != relationship_t::kNone) {
|
||||
|
||||
@@ -166,6 +166,7 @@ public:
|
||||
bool process_field_with_template_instantiation(
|
||||
const cppast::cpp_member_variable &mv, const cppast::cpp_type &tr,
|
||||
clanguml::model::class_diagram::class_ &c,
|
||||
clanguml::model::class_diagram::class_member &m,
|
||||
cppast::cpp_access_specifier_kind as);
|
||||
|
||||
void process_static_field(const cppast::cpp_variable &mv,
|
||||
|
||||
Reference in New Issue
Block a user