Extended generation of method attributes (#142)

This commit is contained in:
Bartek Kryza
2023-05-29 23:19:28 +02:00
parent 75b900bf46
commit 097f7a11ed
13 changed files with 158 additions and 11 deletions

View File

@@ -48,10 +48,57 @@ void class_method::is_defaulted(bool is_defaulted)
is_defaulted_ = is_defaulted;
}
bool class_method::is_deleted() const { return is_deleted_; }
void class_method::is_deleted(bool is_deleted) { is_deleted_ = is_deleted; }
bool class_method::is_static() const { return is_static_; }
void class_method::is_static(bool is_static) { is_static_ = is_static; }
bool class_method::is_constexpr() const { return is_constexpr_; }
void class_method::is_constexpr(bool is_constexpr)
{
is_constexpr_ = is_constexpr;
}
bool class_method::is_consteval() const { return is_consteval_; }
void class_method::is_consteval(bool is_consteval)
{
is_consteval_ = is_consteval;
}
bool class_method::is_noexcept() const { return is_noexcept_; }
void class_method::is_noexcept(bool is_noexcept) { is_noexcept_ = is_noexcept; }
bool class_method::is_constructor() const { return is_constructor_; }
void class_method::is_constructor(bool is_constructor)
{
is_constructor_ = is_constructor;
}
bool class_method::is_move_assignment() const { return is_move_assignment_; }
void class_method::is_move_assignment(bool is_move_assignment)
{
is_move_assignment_ = is_move_assignment;
}
bool class_method::is_copy_assignment() const { return is_copy_assignment_; }
void class_method::is_copy_assignment(bool is_copy_assignment)
{
is_copy_assignment_ = is_copy_assignment;
}
bool class_method::is_operator() const { return is_operator_; }
void class_method::is_operator(bool is_operator) { is_operator_ = is_operator; }
const std::vector<method_parameter> &class_method::parameters() const
{
return parameters_;

View File

@@ -48,9 +48,33 @@ public:
bool is_defaulted() const;
void is_defaulted(bool is_defaulted);
bool is_deleted() const;
void is_deleted(bool is_deleted);
bool is_static() const;
void is_static(bool is_static);
bool is_constexpr() const;
void is_constexpr(bool is_constexpr);
bool is_consteval() const;
void is_consteval(bool is_consteval);
bool is_noexcept() const;
void is_noexcept(bool is_noexcept);
bool is_constructor() const;
void is_constructor(bool is_constructor);
bool is_move_assignment() const;
void is_move_assignment(bool is_move_assignment);
bool is_copy_assignment() const;
void is_copy_assignment(bool is_copy_assignment);
bool is_operator() const;
void is_operator(bool is_operator);
const std::vector<method_parameter> &parameters() const;
void add_parameter(method_parameter &&parameter);
@@ -61,6 +85,14 @@ private:
bool is_virtual_{false};
bool is_const_{false};
bool is_defaulted_{false};
bool is_deleted_{false};
bool is_static_{false};
bool is_noexcept_{false};
bool is_constexpr_{false};
bool is_consteval_{false};
bool is_constructor_{false};
bool is_move_assignment_{false};
bool is_copy_assignment_{false};
bool is_operator_{false};
};
} // namespace clanguml::class_diagram::model

View File

@@ -55,8 +55,12 @@ std::string method_parameter::to_string(
auto name_ns =
using_namespace.relative(common::model::namespace_{name()}.to_string());
if (default_value().empty())
if (default_value().empty()) {
if (name_ns.empty())
return type_ns;
return fmt::format("{} {}", type_ns, name_ns);
}
return fmt::format("{} {} = {}", type_ns, name_ns, default_value());
}