Fixed template template handling

This commit is contained in:
Bartek Kryza
2022-07-28 00:35:14 +02:00
parent 3e4beef80b
commit cf1054aa83
6 changed files with 292 additions and 45 deletions

View File

@@ -78,10 +78,6 @@ std::optional<std::reference_wrapper<const class_>> diagram::get_class(
{
for (const auto &c : classes_) {
const auto full_name = c.get().full_name(false);
if (name ==
"clanguml::t00012::C<std::map<int,std::vector<std::vector<std::"
"vector<std::string>>>>,3,3,3>")
LOG_ERROR("Comparing {} with {}", full_name, name);
if (full_name == name) {
return {c};

View File

@@ -153,7 +153,7 @@ std::string template_parameter::to_string(
}
void template_parameter::find_nested_relationships(
std::vector<std::pair<std::string, common::model::relationship_t>>
std::vector<std::pair<int64_t, common::model::relationship_t>>
&nested_relationships,
common::model::relationship_t hint,
std::function<bool(const std::string &full_name)> condition) const
@@ -161,15 +161,16 @@ void template_parameter::find_nested_relationships(
// If this type argument should be included in the relationship
// just add it and skip recursion (e.g. this is a user defined type)
if (condition(name())) {
nested_relationships.push_back({to_string({}, false), hint});
if(id())
nested_relationships.push_back({id().value(), hint});
}
// Otherwise (e.g. this is a std::shared_ptr) and we're actually
// interested what is stored inside it
else {
for (const auto &template_argument : template_params()) {
if (condition(template_argument.name())) {
if (condition(template_argument.name()) && template_argument.id()) {
nested_relationships.push_back(
{template_argument.to_string({}, false), hint});
{template_argument.id().value(), hint});
}
else {
template_argument.find_nested_relationships(

View File

@@ -20,6 +20,7 @@
#include "common/model/enums.h"
#include "common/model/namespace.h"
#include <optional>
#include <string>
#include <vector>
@@ -41,6 +42,9 @@ public:
void set_type(const std::string &type);
std::string type() const;
void set_id(const int64_t id) { id_ = id; }
std::optional<int64_t> id() const { return id_; }
void set_name(const std::string &name);
std::string name() const;
@@ -87,7 +91,7 @@ public:
void clear_params() { template_params_.clear(); }
void find_nested_relationships(
std::vector<std::pair<std::string, common::model::relationship_t>>
std::vector<std::pair<int64_t, common::model::relationship_t>>
&nested_relationships,
common::model::relationship_t hint,
std::function<bool(const std::string &full_name)> condition) const;
@@ -116,5 +120,7 @@ private:
// Nested template parameters
std::vector<template_parameter> template_params_;
std::optional<int64_t> id_;
};
}