0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::class_diagram::model::method_parameter Class Reference

Model of a method parameter. More...

Detailed Description

Model of a method parameter.

Definition at line 31 of file method_parameter.h.

#include <method_parameter.h>

Public Member Functions

 method_parameter ()=default
 
 method_parameter (std::string type, std::string name, std::string default_value={})
 Constructor.
 
 ~method_parameter () override=default
 
void set_type (const std::string &type)
 Set parameters type.
 
std::string type () const
 Get parameters type.
 
void set_name (const std::string &name)
 Set parameters name.
 
std::string name () const
 Get parameters name.
 
void set_default_value (const std::string &value)
 Set parameters default value.
 
std::string default_value () const
 Get parameters name.
 
std::string to_string (const common::model::namespace_ &using_namespaces) const
 Render the method parameter to a string.
 
- Public Member Functions inherited from clanguml::common::model::decorated_element
virtual ~decorated_element ()=default
 
bool skip () const
 
bool skip_relationship () const
 
std::pair< relationship_t, std::string > get_relationship () const
 
std::string style_spec () const
 
const std::vector< std::shared_ptr< decorators::decorator > > & decorators () const
 
void add_decorators (const std::vector< std::shared_ptr< decorators::decorator > > &decorators)
 
void append (const decorated_element &de)
 
std::optional< comment_tcomment () const
 
void set_comment (const comment_t &c)
 
virtual std::optional< std::string > doxygen_link () const
 

Private Attributes

std::string type_
 
std::string name_
 
std::string default_value_
 

Constructor & Destructor Documentation

◆ method_parameter() [1/2]

clanguml::class_diagram::model::method_parameter::method_parameter ( )
default

◆ method_parameter() [2/2]

clanguml::class_diagram::model::method_parameter::method_parameter ( std::string  type,
std::string  name,
std::string  default_value = {} 
)

Constructor.

Parameters
typeType of the method parameter as string.
nameName of the method parameter.
default_valueDefault value of the parameter or empty.

Definition at line 25 of file method_parameter.cc.

27 : type_{std::move(type)}
28 , name_{std::move(name)}
29 , default_value_{std::move(default_value)}
30{
31}

◆ ~method_parameter()

clanguml::class_diagram::model::method_parameter::~method_parameter ( )
overridedefault

Member Function Documentation

◆ default_value()

std::string clanguml::class_diagram::model::method_parameter::default_value ( ) const

Get parameters name.

Returns
Parameters name.

Definition at line 46 of file method_parameter.cc.

46{ return default_value_; }

◆ name()

std::string clanguml::class_diagram::model::method_parameter::name ( ) const

Get parameters name.

Returns
Parameters name.

Definition at line 39 of file method_parameter.cc.

39{ return name_; }

◆ set_default_value()

void clanguml::class_diagram::model::method_parameter::set_default_value ( const std::string &  value)

Set parameters default value.

Parameters
typeParameters default value as string.

Definition at line 41 of file method_parameter.cc.

42{
43 default_value_ = value;
44}

◆ set_name()

void clanguml::class_diagram::model::method_parameter::set_name ( const std::string &  name)

Set parameters name.

Parameters
typeParameters name.

Definition at line 37 of file method_parameter.cc.

37{ name_ = name; }

◆ set_type()

void clanguml::class_diagram::model::method_parameter::set_type ( const std::string &  type)

Set parameters type.

Parameters
typeParameters type as string.

Definition at line 33 of file method_parameter.cc.

33{ type_ = type; }

◆ to_string()

std::string clanguml::class_diagram::model::method_parameter::to_string ( const common::model::namespace_ using_namespaces) const

Render the method parameter to a string.

Parameters
using_namespacesIf provided, make all namespaces relative to it.
Returns
String representation of the parameter.

Definition at line 48 of file method_parameter.cc.

50{
51 using namespace clanguml::util;
52 auto type_ns =
53 using_namespace.relative(common::model::namespace_{type()}.to_string());
54
55 auto name_ns =
56 using_namespace.relative(common::model::namespace_{name()}.to_string());
57
58 if (default_value().empty()) {
59 if (name_ns.empty())
60 return type_ns;
61
62 return fmt::format("{} {}", type_ns, name_ns);
63 }
64
65 return fmt::format("{} {} = {}", type_ns, name_ns, default_value());
66}

◆ type()

std::string clanguml::class_diagram::model::method_parameter::type ( ) const

Get parameters type.

Returns
Parameters type as string.

Definition at line 35 of file method_parameter.cc.

35{ return type_; }

Member Data Documentation

◆ default_value_

std::string clanguml::class_diagram::model::method_parameter::default_value_
private

Definition at line 101 of file method_parameter.h.

◆ name_

std::string clanguml::class_diagram::model::method_parameter::name_
private

Definition at line 100 of file method_parameter.h.

◆ type_

std::string clanguml::class_diagram::model::method_parameter::type_
private

Definition at line 99 of file method_parameter.h.


The documentation for this class was generated from the following files: