Refactored standard template aliases to configuration file
This commit is contained in:
@@ -64,8 +64,6 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
|||||||
else
|
else
|
||||||
full_name = c.full_name();
|
full_name = c.full_name();
|
||||||
|
|
||||||
// util::replace_all(full_name, "std::basic_string<char>", "std::string");
|
|
||||||
|
|
||||||
if (full_name.empty())
|
if (full_name.empty())
|
||||||
full_name = "<<anonymous>>";
|
full_name = "<<anonymous>>";
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,7 @@ void template_parameter::set_type(const std::string &type) { type_ = type; }
|
|||||||
|
|
||||||
std::string template_parameter::type() const { return type_; }
|
std::string template_parameter::type() const { return type_; }
|
||||||
|
|
||||||
void template_parameter::set_name(const std::string &name)
|
void template_parameter::set_name(const std::string &name) { name_ = name; }
|
||||||
{
|
|
||||||
name_ = name;
|
|
||||||
// TODO: Add a configurable mapping for simplifying non-interesting
|
|
||||||
// std templates
|
|
||||||
util::replace_all(name_, "std::basic_string<char>", "std::string");
|
|
||||||
util::replace_all(name_, "std::basic_string<wchar_t>", "std::wstring");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string template_parameter::name() const
|
std::string template_parameter::name() const
|
||||||
{
|
{
|
||||||
@@ -157,10 +150,6 @@ std::string template_parameter::to_string(
|
|||||||
res += default_value();
|
res += default_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Refactor this to external configurable class
|
|
||||||
util::replace_all(res, "std::basic_string<char>", "std::string");
|
|
||||||
util::replace_all(res, "std::basic_string<wchar_t>", "std::wstring");
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2077,20 +2077,8 @@ const cppast::cpp_type &translation_unit_visitor::resolve_alias_template(
|
|||||||
bool translation_unit_visitor::simplify_system_template(
|
bool translation_unit_visitor::simplify_system_template(
|
||||||
template_parameter &ct, const std::string &full_name)
|
template_parameter &ct, const std::string &full_name)
|
||||||
{
|
{
|
||||||
if (full_name == "std::basic_string<char>") {
|
if (ctx.config().template_aliases().count(full_name) > 0) {
|
||||||
ct.set_name("std::string");
|
ct.set_name(ctx.config().template_aliases().at(full_name));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (full_name == "std::basic_string<wchar_t>") {
|
|
||||||
ct.set_name("std::wstring");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (full_name == "std::basic_string<char16_t>") {
|
|
||||||
ct.set_name("std::u16string");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (full_name == "std::basic_string<char32_t>") {
|
|
||||||
ct.set_name("std::u32string");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -148,6 +148,25 @@ void class_diagram::initialize_relationship_hints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void class_diagram::initialize_template_aliases()
|
||||||
|
{
|
||||||
|
if (!template_aliases().count("std::basic_string<char>")) {
|
||||||
|
template_aliases().insert({"std::basic_string<char>", "std::string"});
|
||||||
|
}
|
||||||
|
if (!template_aliases().count("std::basic_string<wchar_t>")) {
|
||||||
|
template_aliases().insert(
|
||||||
|
{"std::basic_string<wchar_t>", "std::wstring"});
|
||||||
|
}
|
||||||
|
if (!template_aliases().count("std::basic_string<char16_t>")) {
|
||||||
|
template_aliases().insert(
|
||||||
|
{"std::basic_string<char16_t>", "std::u16string"});
|
||||||
|
}
|
||||||
|
if (!template_aliases().count("std::basic_string<char32_t>")) {
|
||||||
|
template_aliases().insert(
|
||||||
|
{"std::basic_string<char32_t>", "std::u32string"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <> void append_value<plantuml>(plantuml &l, const plantuml &r)
|
template <> void append_value<plantuml>(plantuml &l, const plantuml &r)
|
||||||
{
|
{
|
||||||
l.append(r);
|
l.append(r);
|
||||||
@@ -489,8 +508,10 @@ template <> struct convert<class_diagram> {
|
|||||||
get_option(node, rhs.generate_method_arguments);
|
get_option(node, rhs.generate_method_arguments);
|
||||||
get_option(node, rhs.generate_packages);
|
get_option(node, rhs.generate_packages);
|
||||||
get_option(node, rhs.relationship_hints);
|
get_option(node, rhs.relationship_hints);
|
||||||
|
get_option(node, rhs.template_aliases);
|
||||||
|
|
||||||
rhs.initialize_relationship_hints();
|
rhs.initialize_relationship_hints();
|
||||||
|
rhs.initialize_template_aliases();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ struct relationship_hint_t {
|
|||||||
|
|
||||||
using relationship_hints_t = std::map<std::string, relationship_hint_t>;
|
using relationship_hints_t = std::map<std::string, relationship_hint_t>;
|
||||||
|
|
||||||
|
using template_aliases_t = std::map<std::string, std::string>;
|
||||||
|
|
||||||
std::string to_string(const hint_t t);
|
std::string to_string(const hint_t t);
|
||||||
|
|
||||||
struct inheritable_diagram_options {
|
struct inheritable_diagram_options {
|
||||||
@@ -135,6 +137,7 @@ struct inheritable_diagram_options {
|
|||||||
option<std::filesystem::path> relative_to{"relative_to"};
|
option<std::filesystem::path> relative_to{"relative_to"};
|
||||||
option<bool> generate_system_headers{"generate_system_headers", false};
|
option<bool> generate_system_headers{"generate_system_headers", false};
|
||||||
option<relationship_hints_t> relationship_hints{"relationship_hints"};
|
option<relationship_hints_t> relationship_hints{"relationship_hints"};
|
||||||
|
option<template_aliases_t> template_aliases{"template_aliases"};
|
||||||
|
|
||||||
void inherit(const inheritable_diagram_options &parent);
|
void inherit(const inheritable_diagram_options &parent);
|
||||||
};
|
};
|
||||||
@@ -162,6 +165,8 @@ struct class_diagram : public diagram {
|
|||||||
option<layout_hints> layout{"layout"};
|
option<layout_hints> layout{"layout"};
|
||||||
|
|
||||||
void initialize_relationship_hints();
|
void initialize_relationship_hints();
|
||||||
|
|
||||||
|
void initialize_template_aliases();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sequence_diagram : public diagram {
|
struct sequence_diagram : public diagram {
|
||||||
|
|||||||
Reference in New Issue
Block a user