0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
clanguml::config::option< T > Struct Template Reference

Generic configuration option type. More...

Detailed Description

template<typename T>
struct clanguml::config::option< T >

Generic configuration option type.

This class template represents a single configuration option, which can be either a simple type such as bool or std::string or can be a list or dictionary.

If the option is constructed only from default value, it's is_declared member is false, so we can deduce whether user provided the option or not.

For each option type, there has to be defined a YAML decoder and emitter.

Template Parameters
TThe type of the configuration option

Definition at line 66 of file option.h.

#include <option.h>

Public Member Functions

 option (std::string name_, option_inherit_mode im=option_inherit_mode::kOverride)
 
 option (std::string name_, T initial_value, option_inherit_mode im=option_inherit_mode::kOverride)
 
 option (option_with_alt_names_tag, std::string name_, std::vector< std::string > alternate_names_, option_inherit_mode im=option_inherit_mode::kOverride)
 
void set (const T &v)
 Set the option value.
 
void override (const option< T > &o)
 Override option value.
 
void operator() (const T &v)
 
T & operator() ()
 
const T & operator() () const
 
 operator bool () const
 

Public Attributes

std::string name
 
std::vector< std::string > alternate_names
 
value
 
bool is_declared {false}
 
bool has_value {false}
 
option_inherit_mode inheritance_mode
 

Constructor & Destructor Documentation

◆ option() [1/3]

template<typename T >
clanguml::config::option< T >::option ( std::string  name_,
option_inherit_mode  im = option_inherit_mode::kOverride 
)
inline

Definition at line 67 of file option.h.

69 : name{std::move(name_)}
70 , value{}
72 {
73 }

◆ option() [2/3]

template<typename T >
clanguml::config::option< T >::option ( std::string  name_,
initial_value,
option_inherit_mode  im = option_inherit_mode::kOverride 
)
inline

Definition at line 74 of file option.h.

76 : name{std::move(name_)}
77 , value{std::move(initial_value)}
78 , has_value{true}
80 {
81 }

◆ option() [3/3]

template<typename T >
clanguml::config::option< T >::option ( option_with_alt_names_tag  ,
std::string  name_,
std::vector< std::string >  alternate_names_,
option_inherit_mode  im = option_inherit_mode::kOverride 
)
inline

Definition at line 82 of file option.h.

85 : name{std::move(name_)}
86 , alternate_names{std::move(alternate_names_)}
87 , value{}
89 {
90 }

Member Function Documentation

◆ operator bool()

template<typename T >
clanguml::config::option< T >::operator bool ( ) const
inline

Definition at line 129 of file option.h.

129{ return has_value; }

◆ operator()() [1/3]

template<typename T >
T & clanguml::config::option< T >::operator() ( )
inline

Definition at line 125 of file option.h.

125{ return value; }

◆ operator()() [2/3]

template<typename T >
const T & clanguml::config::option< T >::operator() ( ) const
inline

Definition at line 127 of file option.h.

127{ return value; }

◆ operator()() [3/3]

template<typename T >
void clanguml::config::option< T >::operator() ( const T &  v)
inline

Definition at line 123 of file option.h.

123{ set(v); }

◆ override()

template<typename T >
void clanguml::config::option< T >::override ( const option< T > &  o)
inline

Override option value.

This method overrides the option depending on it's inheritance type.

Parameters
oNew option value

Definition at line 111 of file option.h.

112 {
113 if (o.is_declared && inheritance_mode == option_inherit_mode::kAppend) {
114 append_value(value, o.value);
115 is_declared = true;
116 has_value = true;
117 }
118 else if (!is_declared && o.is_declared) {
119 set(o.value);
120 }
121 }

◆ set()

template<typename T >
void clanguml::config::option< T >::set ( const T &  v)
inline

Set the option value.

Parameters
vOption value

Definition at line 97 of file option.h.

98 {
99 value = v;
100 is_declared = true;
101 has_value = true;
102 }

Member Data Documentation

◆ alternate_names

template<typename T >
std::vector<std::string> clanguml::config::option< T >::alternate_names

Alternate option names

Definition at line 135 of file option.h.

◆ has_value

template<typename T >
bool clanguml::config::option< T >::has_value {false}

Whether the option has value, if the option has no default value and wasn't provided in the config this is set to false.

Definition at line 147 of file option.h.

◆ inheritance_mode

template<typename T >
option_inherit_mode clanguml::config::option< T >::inheritance_mode

The inheritance mode for this option

Definition at line 150 of file option.h.

◆ is_declared

template<typename T >
bool clanguml::config::option< T >::is_declared {false}

Whether or not the value was provided by the user or default

Definition at line 141 of file option.h.

◆ name

template<typename T >
std::string clanguml::config::option< T >::name

Option name, it is also the YAML key in the configuration file

Definition at line 132 of file option.h.

◆ value

template<typename T >
T clanguml::config::option< T >::value

Option value

Definition at line 138 of file option.h.


The documentation for this struct was generated from the following file: