SNode.C
Loading...
Searching...
No Matches
net::config::ConfigSection Class Reference

#include <ConfigSection.h>

Inheritance diagram for net::config::ConfigSection:
Collaboration diagram for net::config::ConfigSection:

Public Member Functions

 ConfigSection (ConfigInstance *instance, const std::string &name, const std::string &description)
 
 ConfigSection (const ConfigSection &)=delete
 
 ConfigSection (ConfigSection &&)=delete
 
ConfigSectionoperator= (const ConfigSection &)=delete
 
ConfigSectionoperator= (ConfigSection &&)=delete
 
CLI::Option * addOption (const std::string &name, const std::string &description)
 
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName)
 
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator)
 
template<typename ValueTypeT >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue)
 
template<typename ValueTypeT >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator)
 
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName)
 
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator)
 
template<typename ValueTypeT >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue)
 
template<typename ValueTypeT >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator)
 
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue)
 
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
 
void required (CLI::Option *opt, bool req=true)
 
bool required () const
 
template<typename ValueType >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue)
 
template<typename ValueType >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue, const CLI::Validator &additionalValidator)
 
template<typename ValueType >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue)
 
template<typename ValueType >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue, const CLI::Validator &additionalValidator)
 

Protected Attributes

CLI::App * section = nullptr
 

Private Attributes

ConfigInstanceinstance = nullptr
 
uint8_t requiredCount = 0
 

Detailed Description

Definition at line 65 of file ConfigSection.h.

Constructor & Destructor Documentation

◆ ConfigSection() [1/3]

net::config::ConfigSection::ConfigSection ( ConfigInstance instance,
const std::string &  name,
const std::string &  description 
)

Definition at line 72 of file ConfigSection.cpp.

74 CLI::App* existingSection = instance->getSection(name);
75 section = existingSection != nullptr ? existingSection
76 : instance //
77 ->addSection(name, description + " for instance '" + instance->getInstanceName() + "'")
78 ->disabled()
79 ->group("Sections");
80 }
CLI::App * getSection(const std::string &name) const
CLI::App * addSection(const std::string &name, const std::string &description)
const std::string & getInstanceName() const

References net::config::ConfigInstance::addSection(), net::config::ConfigInstance::getInstanceName(), net::config::ConfigInstance::getSection(), instance, and section.

Referenced by net::config::ConfigConnection::ConfigConnection(), web::http::client::ConfigHTTP::ConfigHTTP(), net::config::ConfigLegacy::ConfigLegacy(), net::config::ConfigPhysicalSocket::ConfigPhysicalSocket(), and net::config::ConfigTls::ConfigTls().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConfigSection() [2/3]

net::config::ConfigSection::ConfigSection ( const ConfigSection )
delete

◆ ConfigSection() [3/3]

net::config::ConfigSection::ConfigSection ( ConfigSection &&  )
delete

Member Function Documentation

◆ addFlag() [1/6]

CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName 
)

Definition at line 131 of file ConfigSection.cpp.

131 {
132 section->disabled(false);
133
134 CLI::Option* opt = section //
135 ->add_flag(name, description)
136 ->type_name(typeName);
137 if (opt->get_configurable()) {
138 opt->group(section->get_formatter()->get_label("Persistent Options"));
139 }
140
141 return opt;
142 }

References section.

Referenced by addFlag().

Here is the caller graph for this function:

◆ addFlag() [2/6]

CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
const CLI::Validator &  additionalValidator 
)

Definition at line 144 of file ConfigSection.cpp.

147 {
148 return addFlag(name, description, typeName) //
149 ->check(additionalValidator);
150 }
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName)

References addFlag().

Here is the call graph for this function:

◆ addFlag() [3/6]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueType  defaultValue 
)

Definition at line 86 of file ConfigSection.hpp.

86 {
87 return addFlag(name, description, typeName) //
88 ->default_val(defaultValue);
89 }

◆ addFlag() [4/6]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueType  defaultValue,
const CLI::Validator &  additionalValidator 
)

Definition at line 92 of file ConfigSection.hpp.

96 {
97 return addFlag(name, description, typeName, defaultValue) //
98 ->check(additionalValidator);
99 }

◆ addFlag() [5/6]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueTypeT  defaultValue 
)

◆ addFlag() [6/6]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueTypeT  defaultValue,
const CLI::Validator &  additionalValidator 
)

Referenced by web::http::client::ConfigHTTP::ConfigHTTP(), net::config::ConfigPhysicalSocket::ConfigPhysicalSocket(), net::config::ConfigTls::ConfigTls(), and net::config::ConfigTlsServer::ConfigTlsServer().

Here is the caller graph for this function:

◆ addFlagFunction() [1/2]

CLI::Option * net::config::ConfigSection::addFlagFunction ( const std::string &  name,
const std::function< void()> &  callback,
const std::string &  description,
const std::string &  typeName,
const std::string &  defaultValue 
)

Definition at line 152 of file ConfigSection.cpp.

156 {
157 section->disabled(false);
158
159 CLI::Option* opt = section //
160 ->add_flag_function(
161 name,
162 [callback](std::int64_t) {
163 callback();
164 },
165 description)
166 ->default_val(defaultValue)
167 ->type_name(typeName)
168 ->take_last();
169 if (opt->get_configurable()) {
170 opt->group(section->get_formatter()->get_label("Persistent Options"));
171 }
172
173 return opt;
174 }

References section.

Referenced by addFlagFunction().

Here is the caller graph for this function:

◆ addFlagFunction() [2/2]

CLI::Option * net::config::ConfigSection::addFlagFunction ( const std::string &  name,
const std::function< void()> &  callback,
const std::string &  description,
const std::string &  typeName,
const std::string &  defaultValue,
const CLI::Validator &  validator 
)

Definition at line 176 of file ConfigSection.cpp.

181 {
182 return addFlagFunction(name, callback, description, typeName, defaultValue) //
183 ->check(validator);
184 }
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue)

References addFlagFunction().

Referenced by net::config::ConfigPhysicalSocket::addSocketOption(), net::config::ConfigPhysicalSocket::ConfigPhysicalSocket(), and net::config::ConfigPhysicalSocketClient::ConfigPhysicalSocketClient().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOption() [1/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description 
)

Definition at line 103 of file ConfigSection.cpp.

103 {
104 if (!instance->getInstanceName().empty() && !section->get_display_name().empty()) {
105 section->disabled(false);
106 }
107
108 CLI::Option* opt = section //
109 ->add_option(name, description);
110
111 if (opt->get_configurable()) {
112 opt->group(section->get_formatter()->get_label("Persistent Options"));
113 }
114
115 return opt;
116 }

References net::config::ConfigInstance::getInstanceName(), instance, and section.

Referenced by addOption().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOption() [2/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName 
)

Definition at line 118 of file ConfigSection.cpp.

118 {
119 return addOption(name, description) //
120 ->type_name(typeName);
121 }
CLI::Option * addOption(const std::string &name, const std::string &description)

References addOption().

Referenced by addOption().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOption() [3/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
const CLI::Validator &  additionalValidator 
)

Definition at line 123 of file ConfigSection.cpp.

126 {
127 return addOption(name, description, typeName) //
128 ->check(additionalValidator);
129 }

References addOption().

Here is the call graph for this function:

◆ addOption() [4/7]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueType  defaultValue 
)

Definition at line 69 of file ConfigSection.hpp.

69 {
70 return addOption(name, description, typeName) //
71 ->default_val(defaultValue);
72 }

◆ addOption() [5/7]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueType  defaultValue,
const CLI::Validator &  additionalValidator 
)

Definition at line 75 of file ConfigSection.hpp.

79 {
80 return addOption(name, description, typeName, defaultValue) //
81 ->check(additionalValidator);
82 }

◆ addOption() [6/7]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueTypeT  defaultValue 
)

Referenced by net::config::ConfigTls::ConfigTls().

Here is the caller graph for this function:

◆ addOption() [7/7]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addOption ( const std::string &  name,
const std::string &  description,
const std::string &  typeName,
ValueTypeT  defaultValue,
const CLI::Validator &  additionalValidator 
)

Referenced by net::config::ConfigTls::ConfigTls(), and net::config::ConfigTlsClient::ConfigTlsClient().

Here is the caller graph for this function:

◆ operator=() [1/2]

ConfigSection & net::config::ConfigSection::operator= ( ConfigSection &&  )
delete

◆ operator=() [2/2]

ConfigSection & net::config::ConfigSection::operator= ( const ConfigSection )
delete

◆ required() [1/2]

bool net::config::ConfigSection::required ( ) const

Definition at line 99 of file ConfigSection.cpp.

99 {
100 return requiredCount > 0;
101 }

References requiredCount.

◆ required() [2/2]

void net::config::ConfigSection::required ( CLI::Option *  opt,
bool  req = true 
)

Definition at line 82 of file ConfigSection.cpp.

82 {
83 if (req != opt->get_required()) {
84 if (req) {
86 section->needs(opt);
87 opt->default_str("");
88 } else {
90 section->remove_needs(opt);
91 }
92
93 opt->required(req);
94
96 }
97 }
void required(CLI::App *section, bool req=true)

References instance, net::config::ConfigInstance::required(), requiredCount, and section.

Here is the call graph for this function:

Member Data Documentation

◆ instance

ConfigInstance* net::config::ConfigSection::instance = nullptr
private

Definition at line 133 of file ConfigSection.h.

Referenced by addOption(), ConfigSection(), and required().

◆ requiredCount

uint8_t net::config::ConfigSection::requiredCount = 0
private

Definition at line 135 of file ConfigSection.h.

Referenced by required(), and required().

◆ section

CLI::App* net::config::ConfigSection::section = nullptr
protected

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