0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
common
model
template_trait.cc
Go to the documentation of this file.
1
/**
2
* @file src/common/model/template_trait.cc
3
*
4
* Copyright (c) 2021-2025 Bartek Kryza <bkryza@gmail.com>
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
#include "
common/model/template_trait.h
"
20
21
namespace
clanguml::common::model
{
22
23
std::ostream &
template_trait::render_template_params
(std::ostream &ostr,
24
const
common::model::namespace_
&using_namespace,
bool
relative)
const
25
{
26
using
clanguml::common::model::namespace_
;
27
28
if
(!
template_params
().
empty
()) {
29
std::vector<std::string> tnames;
30
31
std::transform(
template_params
().cbegin(),
template_params
().cend(),
32
std::back_inserter(tnames),
33
[ns = using_namespace, relative](
34
const
auto
&tmplt) {
return
tmplt.to_string(ns, relative); });
35
36
if
(
template_params
().size() > 1 &&
37
template_params
().back().kind() ==
template_parameter_kind_t::empty
)
38
ostr << fmt::format(
39
"<{}>"
, fmt::join(tnames.begin(), tnames.end() - 1,
","
));
40
41
else
42
ostr << fmt::format(
"<{}>"
, fmt::join(tnames,
","
));
43
}
44
45
return
ostr;
46
}
47
48
void
template_trait::add_template
(
template_parameter
&&tmplt)
49
{
50
templates_
.push_back(std::move(tmplt));
51
}
52
53
const
std::vector<template_parameter> &
template_trait::template_params
()
const
54
{
55
return
templates_
;
56
}
57
58
int
template_trait::calculate_template_specialization_match
(
59
const
template_trait
&base_template)
const
60
{
61
return
calculate_template_params_specialization_match
(
62
template_params
(), base_template.
template_params
());
63
}
64
65
}
// namespace clanguml::common::model
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7