WIP Refactoring alias template resolution based on clang canonical representation
This commit is contained in:
@@ -139,10 +139,13 @@ std::ostringstream &class_::render_template_params(
|
||||
|
||||
if (!templates_.empty()) {
|
||||
std::vector<std::string> tnames;
|
||||
std::vector<std::string> tnames_simplified;
|
||||
|
||||
std::transform(templates_.cbegin(), templates_.cend(),
|
||||
std::back_inserter(tnames), [this](const auto &tmplt) {
|
||||
return tmplt.to_string(using_namespace());
|
||||
});
|
||||
std::back_inserter(tnames),
|
||||
[ns = using_namespace()](
|
||||
const auto &tmplt) { return tmplt.to_string(ns); });
|
||||
|
||||
ostr << fmt::format("<{}>", fmt::join(tnames, ","));
|
||||
}
|
||||
return ostr;
|
||||
|
||||
@@ -75,12 +75,17 @@ public:
|
||||
|
||||
bool is_abstract() const;
|
||||
|
||||
bool is_alias() const { return is_alias_; }
|
||||
|
||||
void is_alias(bool alias) { is_alias_ = alias; }
|
||||
|
||||
private:
|
||||
std::ostringstream &render_template_params(std::ostringstream &ostr) const;
|
||||
|
||||
bool is_struct_{false};
|
||||
bool is_template_{false};
|
||||
bool is_template_instantiation_{false};
|
||||
bool is_alias_{false};
|
||||
std::vector<class_member> members_;
|
||||
std::vector<class_method> methods_;
|
||||
std::vector<class_parent> bases_;
|
||||
|
||||
@@ -24,16 +24,21 @@ namespace clanguml::class_diagram::model {
|
||||
|
||||
class_template::class_template(const std::string &type, const std::string &name,
|
||||
const std::string &default_value, bool is_variadic)
|
||||
: type_{type}
|
||||
, name_{name}
|
||||
: name_{name}
|
||||
, default_value_{default_value}
|
||||
, is_variadic_{is_variadic}
|
||||
{
|
||||
set_type(type);
|
||||
if (is_variadic)
|
||||
name_ = name_ + "...";
|
||||
}
|
||||
|
||||
void class_template::set_type(const std::string &type) { type_ = type; }
|
||||
void class_template::set_type(const std::string &type) {
|
||||
type_ = type;
|
||||
// TODO: Add a configurable mapping for simplifying non-interesting
|
||||
// std templates
|
||||
util::replace_all(type_, "std::basic_string<char>", "std::string");
|
||||
}
|
||||
|
||||
std::string class_template::type() const { return type_; }
|
||||
|
||||
@@ -60,6 +65,11 @@ bool operator==(const class_template &l, const class_template &r)
|
||||
return (l.name() == r.name()) && (l.type() == r.type());
|
||||
}
|
||||
|
||||
bool operator!=(const class_template &l, const class_template &r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
std::string class_template::to_string(
|
||||
const clanguml::common::model::namespace_ &using_namespace) const
|
||||
{
|
||||
|
||||
@@ -42,9 +42,17 @@ public:
|
||||
bool is_variadic() const noexcept;
|
||||
|
||||
friend bool operator==(const class_template &l, const class_template &r);
|
||||
friend bool operator!=(const class_template &l, const class_template &r);
|
||||
|
||||
std::vector<class_template> template_params_;
|
||||
|
||||
bool is_template_parameter() const { return is_template_parameter_; }
|
||||
|
||||
void is_template_parameter(bool is_template_parameter)
|
||||
{
|
||||
is_template_parameter_ = is_template_parameter;
|
||||
}
|
||||
|
||||
std::string to_string(
|
||||
const clanguml::common::model::namespace_ &using_namespace) const;
|
||||
|
||||
@@ -52,6 +60,7 @@ private:
|
||||
std::string type_;
|
||||
std::string name_;
|
||||
std::string default_value_;
|
||||
bool is_template_parameter_{false};
|
||||
bool is_variadic_{false};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user