Added generation of type alias map
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -140,6 +141,11 @@ struct class_template {
|
||||
}
|
||||
};
|
||||
|
||||
struct type_alias {
|
||||
std::string alias;
|
||||
std::string underlying_type;
|
||||
};
|
||||
|
||||
class class_ : public element {
|
||||
public:
|
||||
std::string usr;
|
||||
@@ -153,12 +159,20 @@ public:
|
||||
std::vector<class_relationship> relationships;
|
||||
std::vector<class_template> templates;
|
||||
std::string base_template_usr;
|
||||
std::map<std::string, type_alias> type_aliases;
|
||||
|
||||
friend bool operator==(const class_ &l, const class_ &r)
|
||||
{
|
||||
return (l.usr == r.usr) && (l.templates == r.templates);
|
||||
}
|
||||
|
||||
void add_type_alias(type_alias &&ta)
|
||||
{
|
||||
spdlog::debug(
|
||||
"Adding class alias: {} -> {}", ta.alias, ta.underlying_type);
|
||||
type_aliases[ta.alias] = std::move(ta);
|
||||
}
|
||||
|
||||
void add_relationship(class_relationship &&cr)
|
||||
{
|
||||
auto it = std::find(relationships.begin(), relationships.end(), cr);
|
||||
@@ -225,6 +239,7 @@ struct diagram {
|
||||
std::string name;
|
||||
std::vector<class_> classes;
|
||||
std::vector<enum_> enums;
|
||||
std::map<std::string, type_alias> type_aliases;
|
||||
|
||||
bool has_class(const std::string &usr) const
|
||||
{
|
||||
@@ -232,6 +247,14 @@ struct diagram {
|
||||
[&usr](const auto &c) { return c.usr == usr; });
|
||||
}
|
||||
|
||||
void add_type_alias(type_alias &&ta)
|
||||
{
|
||||
spdlog::debug(
|
||||
"Adding global alias: {} -> {}", ta.alias, ta.underlying_type);
|
||||
|
||||
type_aliases[ta.alias] = std::move(ta);
|
||||
}
|
||||
|
||||
void add_class(class_ &&c)
|
||||
{
|
||||
spdlog::debug("Adding class: {}, {}", c.name, c.usr);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <cppast/cpp_member_function.hpp>
|
||||
#include <cppast/cpp_member_variable.hpp>
|
||||
#include <cppast/cpp_template.hpp>
|
||||
#include <cppast/cpp_type_alias.hpp>
|
||||
#include <cppast/cpp_variable.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
@@ -43,6 +44,7 @@ using clanguml::model::class_diagram::enum_;
|
||||
using clanguml::model::class_diagram::method_parameter;
|
||||
using clanguml::model::class_diagram::relationship_t;
|
||||
using clanguml::model::class_diagram::scope_t;
|
||||
using clanguml::model::class_diagram::type_alias;
|
||||
|
||||
namespace detail {
|
||||
scope_t cpp_access_specifier_to_scope(cppast::cpp_access_specifier_kind as)
|
||||
@@ -97,6 +99,18 @@ void tu_visitor::operator()(const cppast::cpp_entity &file)
|
||||
if (ctx.config.should_include(cx::util::fully_prefixed(enm)))
|
||||
process_enum_declaration(enm);
|
||||
}
|
||||
else if (e.kind() == cppast::cpp_entity_kind::type_alias_t) {
|
||||
spdlog::debug("========== Visiting '{}' - {}",
|
||||
cx::util::full_name(e), cppast::to_string(e.kind()));
|
||||
|
||||
auto &ta = static_cast<const cppast::cpp_type_alias &>(e);
|
||||
type_alias t;
|
||||
t.alias = cx::util::full_name(ta);
|
||||
t.underlying_type = cx::util::full_name(ta.underlying_type(),
|
||||
ctx.entity_index, cx::util::is_inside_class(e));
|
||||
|
||||
ctx.d.add_type_alias(std::move(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user