Initial support for concept dependency relationships in class diagrams

This commit is contained in:
Bartek Kryza
2023-02-25 01:50:07 +01:00
parent 20a0f2d338
commit 274a698713
15 changed files with 750 additions and 34 deletions

View File

@@ -138,6 +138,8 @@ std::string template_parameter::to_string(
{
using clanguml::common::model::namespace_;
assert(!(!type().empty() && concept_constraint().has_value()));
std::string res;
if (!type().empty()) {
if (!relative)
@@ -146,8 +148,17 @@ std::string template_parameter::to_string(
res += namespace_{type()}.relative_to(using_namespace).to_string();
}
if (concept_constraint()) {
if (!relative)
res += namespace_{concept_constraint().value()}.to_string();
else
res += namespace_{concept_constraint().value()}
.relative_to(using_namespace)
.to_string();
}
if (!name().empty()) {
if (!type().empty())
if (!type().empty() || concept_constraint())
res += " ";
if (!relative)
res += namespace_{name()}.to_string();
@@ -216,4 +227,14 @@ bool template_parameter::find_nested_relationships(
return added_aggregation_relationship;
}
void template_parameter::set_concept_constraint(std::string constraint)
{
concept_constraint_ = std::move(constraint);
}
const std::optional<std::string> &template_parameter::concept_constraint() const
{
return concept_constraint_;
}
} // namespace clanguml::common::model

View File

@@ -100,6 +100,9 @@ public:
const std::function<bool(const std::string &full_name)> &should_include)
const;
void set_concept_constraint(std::string constraint);
const std::optional<std::string> &concept_constraint() const;
private:
/// Represents the type of non-type template parameters
/// e.g. 'int'
@@ -125,6 +128,10 @@ private:
/// Whether the argument specializes argument pack from parent template
bool is_pack_{false};
/// Stores optional fully qualified name of constraint for this template
/// parameter
std::optional<std::string> concept_constraint_;
// Nested template parameters
std::vector<template_parameter> template_params_;