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 78 of file ConfigSection.cpp.

80 CLI::App* existingSection = instance->getSection(name);
81 section = existingSection != nullptr ? existingSection
82 : instance //
83 ->addSection(name, description + " for instance '" + instance->getInstanceName() + "'")
84 ->disabled()
85 ->group("Sections");
86 }

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 137 of file ConfigSection.cpp.

137 {
138 section->disabled(false);
139
140 CLI::Option* opt = section //
141 ->add_flag(name, description)
142 ->type_name(typeName);
143 if (opt->get_configurable()) {
144 opt->group(section->get_formatter()->get_label("Persistent Options"));
145 }
146
147 return opt;
148 }

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 150 of file ConfigSection.cpp.

153 {
154 return addFlag(name, description, typeName) //
155 ->check(additionalValidator);
156 }
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 92 of file ConfigSection.hpp.

92 {
93 return addFlag(name, description, typeName) //
94 ->default_val(defaultValue);
95 }

◆ 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 98 of file ConfigSection.hpp.

102 {
103 return addFlag(name, description, typeName, defaultValue) //
104 ->check(additionalValidator);
105 }

◆ 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 158 of file ConfigSection.cpp.

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

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 182 of file ConfigSection.cpp.

187 {
188 return addFlagFunction(name, callback, description, typeName, defaultValue) //
189 ->check(validator);
190 }
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 109 of file ConfigSection.cpp.

109 {
110 if (!instance->getInstanceName().empty() && !section->get_display_name().empty()) {
111 section->disabled(false);
112 }
113
114 CLI::Option* opt = section //
115 ->add_option(name, description);
116
117 if (opt->get_configurable()) {
118 opt->group(section->get_formatter()->get_label("Persistent Options"));
119 }
120
121 return opt;
122 }

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 124 of file ConfigSection.cpp.

124 {
125 return addOption(name, description) //
126 ->type_name(typeName);
127 }
CLI::Option * addOption(const std::string &name, const std::string &description)

References addOption().

Referenced by addOption(), and web::http::client::ConfigHTTP::ConfigHTTP().

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 129 of file ConfigSection.cpp.

132 {
133 return addOption(name, description, typeName) //
134 ->check(additionalValidator);
135 }

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 75 of file ConfigSection.hpp.

75 {
76 return addOption(name, description, typeName) //
77 ->default_val(defaultValue);
78 }

◆ 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 81 of file ConfigSection.hpp.

85 {
86 return addOption(name, description, typeName, defaultValue) //
87 ->check(additionalValidator);
88 }

◆ 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 105 of file ConfigSection.cpp.

105 {
106 return requiredCount > 0;
107 }

References requiredCount.

◆ required() [2/2]

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

Definition at line 88 of file ConfigSection.cpp.

88 {
89 if (req != opt->get_required()) {
90 if (req) {
92 section->needs(opt);
93 opt->default_str("");
94 } else {
96 section->remove_needs(opt);
97 }
98
99 opt->required(req);
100
101 instance->required(section, requiredCount > 0);
102 }
103 }

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

Referenced by main().

Here is the call graph for this function:
Here is the caller 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: