Refactored stylable_element

This commit is contained in:
Bartek Kryza
2021-09-26 23:50:27 +02:00
parent 80ee88aa4b
commit d6b88e68ec
4 changed files with 23 additions and 11 deletions

View File

@@ -130,8 +130,8 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
ostr << class_type << " " << c.alias();
if (!c.style.empty())
ostr << " " << c.style;
if (!c.style().empty())
ostr << " " << c.style();
ostr << " {" << '\n';
@@ -203,7 +203,7 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
if (!r.multiplicity_source.empty())
puml_relation += "\"" + r.multiplicity_source + "\" ";
puml_relation += to_string(r.type, r.style);
puml_relation += to_string(r.type, r.style());
if (!r.multiplicity_destination.empty())
puml_relation += " \"" + r.multiplicity_destination + "\"";
@@ -290,8 +290,8 @@ void generator::generate(const enum_ &e, std::ostream &ostr) const
{
ostr << "enum " << e.alias();
if (!e.style.empty())
ostr << " " << e.style;
if (!e.style().empty())
ostr << " " << e.style();
ostr << " {" << '\n';

View File

@@ -51,6 +51,13 @@ std::string to_string(relationship_t r)
}
}
//
// stylable_element
//
void stylable_element::set_style(const std::string &style) { style_ = style; }
std::string stylable_element::style() const { return style_; }
//
// decorated_element
//

View File

@@ -54,8 +54,13 @@ enum class relationship_t {
std::string to_string(relationship_t r);
struct stylable_element {
std::string style;
class stylable_element {
public:
void set_style(const std::string &style);
std::string style() const;
private:
std::string style_;
};
struct decorated_element {

View File

@@ -288,7 +288,7 @@ void tu_visitor::process_enum_declaration(const cppast::cpp_enum &enm)
if (e.skip())
return;
e.style = e.style_spec();
e.set_style(e.style_spec());
// Process enum documentation comment
if (enm.comment().has_value())
@@ -347,7 +347,7 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls,
if (c.skip())
return;
c.style = c.style_spec();
c.set_style(c.style_spec());
// Process class child entities
if (c.is_struct())
@@ -633,7 +633,7 @@ 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();
rr.set_style(m.style_spec());
// Process field decorators
auto [decorator_rtype, decorator_rmult] = m.relationship();
@@ -718,7 +718,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();
r.set_style(m.style_spec());
auto [decorator_rtype, decorator_rmult] = m.relationship();
if (decorator_rtype != relationship_t::kNone) {