Represents template parameter, template arguments or concept constraints. More...
Represents template parameter, template arguments or concept constraints.
This class can represent both template parameter and template arguments, including variadic parameters and instantiations with nested templates
Definition at line 82 of file template_parameter.h.
#include <template_parameter.h>
Public Member Functions | |
void | set_type (const std::string &type) |
std::optional< std::string > | type () const |
void | set_id (const eid_t &id) |
const std::optional< eid_t > & | id () const |
void | set_name (const std::string &name) |
std::optional< std::string > | name () const |
void | set_default_value (const std::string &value) |
const std::optional< std::string > & | default_value () const |
void | is_variadic (bool is_variadic) noexcept |
bool | is_variadic () const noexcept |
int | calculate_specialization_match (const template_parameter &base_template_parameter) const |
Calculate the match between this and other parameter. | |
bool | is_template_parameter () const |
void | is_template_parameter (bool is_template_parameter) |
bool | is_template_template_parameter () const |
void | is_template_template_parameter (bool is_template_template_parameter) |
bool | is_unexposed () const |
void | set_unexposed (bool unexposed) |
void | is_function_template (bool ft) |
bool | is_function_template () const |
void | is_member_pointer (bool m) |
bool | is_member_pointer () const |
void | is_data_pointer (bool m) |
bool | is_data_pointer () const |
void | is_array (bool a) |
bool | is_array () const |
void | add_template_param (template_parameter &&ct) |
void | add_template_param (const template_parameter &ct) |
const std::vector< template_parameter > & | template_params () const |
void | clear_params () |
bool | is_association () const |
bool | is_specialization () const |
bool | is_same_specialization (const template_parameter &other) const |
Whether this is the same type of specialization as other. | |
bool | find_nested_relationships (std::vector< std::pair< eid_t, common::model::relationship_t > > &nested_relationships, common::model::relationship_t hint, const std::function< bool(const std::string &full_name)> &should_include) const |
Find all relationships in this and its nested templates. | |
void | set_concept_constraint (std::string constraint) |
const std::optional< std::string > & | concept_constraint () const |
template_parameter_kind_t | kind () const |
void | set_kind (template_parameter_kind_t kind) |
void | push_context (const context &q) |
Append a deduced context to the template parameter. | |
const std::deque< context > & | deduced_context () const |
void | deduced_context (std::deque< context > c) |
void | is_ellipsis (bool e) |
bool | is_ellipsis () const |
std::string | to_string (const clanguml::common::model::namespace_ &using_namespace, bool relative, bool skip_qualifiers=false) const |
Render the template_parameter into string. | |
Static Public Member Functions | |
static template_parameter | make_template_type (const std::string &name, const std::optional< std::string > &default_value={}, bool is_variadic=false) |
Build template type parameter. | |
static template_parameter | make_template_template_type (const std::string &name, const std::optional< std::string > &default_value={}, bool is_variadic=false) |
Build template template parameter type. | |
static template_parameter | make_non_type_template (const std::string &type, const std::optional< std::string > &name, const std::optional< std::string > &default_value={}, bool is_variadic=false) |
Build non-type template parameter. | |
static template_parameter | make_argument (const std::string &type, const std::optional< std::string > &default_value={}) |
Build template argument. | |
static template_parameter | make_unexposed_argument (const std::string &type, const std::optional< std::string > &default_value={}) |
Build template argument with unexposed type. | |
Private Member Functions | |
template_parameter ()=default | |
std::string | deduced_context_str () const |
Private Attributes | |
template_parameter_kind_t | kind_ {template_parameter_kind_t::template_type} |
std::optional< std::string > | type_ |
std::optional< std::string > | name_ |
std::optional< std::string > | default_value_ |
bool | is_template_parameter_ {false} |
bool | is_template_template_parameter_ {false} |
bool | is_ellipsis_ {false} |
bool | is_variadic_ {false} |
bool | is_function_template_ {false} |
bool | is_data_pointer_ {false} |
bool | is_member_pointer_ {false} |
bool | is_array_ {false} |
std::deque< context > | context_ |
std::optional< std::string > | concept_constraint_ |
std::vector< template_parameter > | template_params_ |
std::optional< eid_t > | id_ |
bool | is_unexposed_ {false} |
|
privatedefault |
This class should be only constructed using builder methods.
void clanguml::common::model::template_parameter::add_template_param | ( | const template_parameter & | ct | ) |
Add a nested template parameter.
ct | Template parameter l-value. |
Definition at line 324 of file template_parameter.cc.
void clanguml::common::model::template_parameter::add_template_param | ( | template_parameter && | ct | ) |
Add a nested template parameter.
ct | Template parameter r-value. |
Definition at line 319 of file template_parameter.cc.
int clanguml::common::model::template_parameter::calculate_specialization_match | ( | const template_parameter & | base_template_parameter | ) | const |
Calculate the match between this and other parameter.
This method calculates to what degree *this matches the base_template_parameter
as it's less specific specialization.
The higher the value, the more likely it is that *this is a specialization of base_template_parameter
.
base_template_parameter |
Definition at line 229 of file template_parameter.cc.
|
inline |
Erase all nested template parameters.
Definition at line 347 of file template_parameter.h.
const std::optional< std::string > & clanguml::common::model::template_parameter::concept_constraint | ( | ) | const |
Get the name of the concept constraint for this parameter, if any
Definition at line 565 of file template_parameter.cc.
const std::deque< context > & clanguml::common::model::template_parameter::deduced_context | ( | ) | const |
Get the entire deduce context of the template parameter
Definition at line 619 of file template_parameter.cc.
void clanguml::common::model::template_parameter::deduced_context | ( | std::deque< context > | c | ) |
Set the deduced context for the template parameter
c | Deduced context. |
Definition at line 624 of file template_parameter.cc.
|
private |
Definition at line 335 of file template_parameter.cc.
const std::optional< std::string > & clanguml::common::model::template_parameter::default_value | ( | ) | const |
Get the template parameters default value if any
Definition at line 217 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::find_nested_relationships | ( | std::vector< std::pair< eid_t, common::model::relationship_t > > & | nested_relationships, |
common::model::relationship_t | hint, | ||
const std::function< bool(const std::string &full_name)> & | should_include | ||
) | const |
Find all relationships in this and its nested templates.
nested_relationships | Output to store found relationships |
hint | Provide hint for the found relationships |
should_include | Functor to determine whether nested template parameter or argument should be considered |
Definition at line 479 of file template_parameter.cc.
|
inline |
Get id of the template parameter
Definition at line 172 of file template_parameter.h.
bool clanguml::common::model::template_parameter::is_array | ( | ) | const |
Whether this is an array template parameter.
Definition at line 612 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_array | ( | bool | a | ) |
Set, whether this is an array template parameter.
m | Array parameter status |
Definition at line 611 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_association | ( | ) | const |
Does the template parameters deduced context contain any references or pointers?
Definition at line 570 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_data_pointer | ( | ) | const |
Whether this is a data pointer parameter.
Definition at line 609 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_data_pointer | ( | bool | m | ) |
Set, whether this is a data template parameter.
m | Data pointer parameter status |
Definition at line 608 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_ellipsis | ( | ) | const |
Check whether the parameter is an ellipsis
Definition at line 631 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_ellipsis | ( | bool | e | ) |
Set, whether the parameter is an ellipsis (...)
e | True, if parameter is an ellipsis |
Definition at line 629 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_function_template | ( | ) | const |
Whether this is a function template parameter.
Definition at line 597 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_function_template | ( | bool | ft | ) |
Set, whether this is a function template parameter.
ft | Function template parameter status |
Definition at line 593 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_member_pointer | ( | ) | const |
Whether this is a member pointer parameter.
Definition at line 603 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_member_pointer | ( | bool | m | ) |
Set, whether this is a member pointer template parameter.
m | Member pointer template parameter status |
Definition at line 602 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_same_specialization | ( | const template_parameter & | other | ) | const |
Whether this is the same type of specialization as other.
This method is used for instance to check if 2 template parameters are function templates.
other | Another template parameter or argument |
Definition at line 147 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_specialization | ( | ) | const |
Is this template argument or parameter a specialization of some more generic template.
Definition at line 141 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_template_parameter | ( | ) | const |
Whether this is a template parameter.
Definition at line 539 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_template_parameter | ( | bool | is_template_parameter | ) |
Set, whether this is a template parameter.
is_template_parameter | Template parameter status |
Definition at line 544 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_template_template_parameter | ( | ) | const |
Whether this is a template template parameter.
Definition at line 549 of file template_parameter.cc.
void clanguml::common::model::template_parameter::is_template_template_parameter | ( | bool | is_template_template_parameter | ) |
Set, whether this is a template template parameter.
is_template_parameter | Template template parameter status |
Definition at line 554 of file template_parameter.cc.
bool clanguml::common::model::template_parameter::is_unexposed | ( | ) | const |
Definition at line 586 of file template_parameter.cc.
|
noexcept |
Check whether template parameter is variadic
Definition at line 227 of file template_parameter.cc.
|
noexcept |
Set template parameters variadic status.
is_variadic | True, if template parameter is variadic |
Definition at line 222 of file template_parameter.cc.
template_parameter_kind_t clanguml::common::model::template_parameter::kind | ( | ) | const |
Get the kind of the template parameter or argument
Definition at line 579 of file template_parameter.cc.
|
static |
Build template argument.
type | Type of template argument |
default_value | Default value of the parameter if any |
Definition at line 122 of file template_parameter.cc.
|
static |
Build non-type template parameter.
type | Type of non-type parameter (e.g. int) |
name | Name of parameter |
default_value | Default value of the parameter if any |
is_variadic | Whether the template parameter is variadic |
Definition at line 107 of file template_parameter.cc.
|
static |
Build template template parameter type.
name | Name of template template parameter |
default_value | Default value of the parameter if any |
is_variadic | Whether the template parameter is variadic |
Definition at line 94 of file template_parameter.cc.
|
static |
Build template type parameter.
name | Name of template parameter (e.g. T) |
default_value | Default value of the parameter if any |
is_variadic | Whether the template parameter is variadic |
Definition at line 80 of file template_parameter.cc.
|
static |
Build template argument with unexposed type.
This method is used to build template argument from an unexposed string, i.e. when Clang just returns a string for the template argument type instead of actual type AST.
type | String representation of the type |
default_value | Default value of the parameter if any |
Definition at line 133 of file template_parameter.cc.
std::optional< std::string > clanguml::common::model::template_parameter::name | ( | ) | const |
Get the name of template parameter, if any
Definition at line 195 of file template_parameter.cc.
void clanguml::common::model::template_parameter::push_context | ( | const context & | q | ) |
Append a deduced context to the template parameter.
q | Deduced context |
Definition at line 614 of file template_parameter.cc.
void clanguml::common::model::template_parameter::set_concept_constraint | ( | std::string | constraint | ) |
Set the concept constraint for this template parameter
constraint |
Definition at line 560 of file template_parameter.cc.
void clanguml::common::model::template_parameter::set_default_value | ( | const std::string & | value | ) |
Set default value for template parameter
value | Default value |
Definition at line 210 of file template_parameter.cc.
|
inline |
Set unique id for the template parameter or argument
id | Id of parameter |
Definition at line 165 of file template_parameter.h.
void clanguml::common::model::template_parameter::set_kind | ( | template_parameter_kind_t | kind | ) |
Set the kind of the template parameter or argument.
kind | Kind of the template parameter |
Definition at line 581 of file template_parameter.cc.
void clanguml::common::model::template_parameter::set_name | ( | const std::string & | name | ) |
Set the name of the template parameter
name | Name of template parameter |
Definition at line 179 of file template_parameter.cc.
void clanguml::common::model::template_parameter::set_type | ( | const std::string & | type | ) |
Set the type of template argument
type | Name of the type |
Definition at line 156 of file template_parameter.cc.
void clanguml::common::model::template_parameter::set_unexposed | ( | bool | unexposed | ) |
Definition at line 588 of file template_parameter.cc.
const std::vector< template_parameter > & clanguml::common::model::template_parameter::template_params | ( | ) | const |
Get the reference to all nested template parameters.
Definition at line 330 of file template_parameter.cc.
std::string clanguml::common::model::template_parameter::to_string | ( | const clanguml::common::model::namespace_ & | using_namespace, |
bool | relative, | ||
bool | skip_qualifiers = false |
||
) | const |
Render the template_parameter into string.
This method renders the template parameter along with any of its nested template parameters
using_namespace | |
relative | |
skip_qualifiers |
Definition at line 346 of file template_parameter.cc.
std::optional< std::string > clanguml::common::model::template_parameter::type | ( | ) | const |
Get the type of template parameter if any
Definition at line 168 of file template_parameter.cc.
|
private |
Stores optional fully qualified name of constraint for this template parameter
Definition at line 525 of file template_parameter.h.
|
private |
Stores the template parameter/argument deduction context e.g. const&
Definition at line 520 of file template_parameter.h.
|
private |
Default value of the template parameter
Definition at line 489 of file template_parameter.h.
|
private |
Definition at line 532 of file template_parameter.h.
|
private |
Is template argument an array
Definition at line 517 of file template_parameter.h.
|
private |
Whether the template
Definition at line 511 of file template_parameter.h.
|
private |
Whether template argument is ellipsis (...)
Definition at line 502 of file template_parameter.h.
|
private |
Whether the template is a function template (e.g. R(T))
Definition at line 508 of file template_parameter.h.
|
private |
Whether the template is a member pointer (e.g. R(C::*)(int))
Definition at line 514 of file template_parameter.h.
|
private |
Whether the template parameter is a regular template parameter. When false, it is a non-type template parameter
Definition at line 494 of file template_parameter.h.
|
private |
Whether the template parameter is a template template parameter. Can only be true when is_template_parameter_ is true
Definition at line 499 of file template_parameter.h.
|
private |
Definition at line 534 of file template_parameter.h.
|
private |
Whether the template parameter is variadic
Definition at line 505 of file template_parameter.h.
|
private |
Definition at line 478 of file template_parameter.h.
|
private |
The name of the parameter (e.g. 'T' or 'N')
Definition at line 486 of file template_parameter.h.
|
private |
Nested template parameters. If this is a function template, the first element is the return type
Definition at line 530 of file template_parameter.h.
|
private |
Represents the type of non-type template parameters e.g. 'int' or type of template arguments
Definition at line 483 of file template_parameter.h.