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

52 CLI::App* existingSection = instance->getSection(name);
53 section = existingSection != nullptr ? existingSection
54 : instance //
55 ->addSection(name, description + " for instance '" + instance->getInstanceName() + "'")
56 ->disabled()
57 ->group("Sections");
58 }
CLI::App * getSection(const std::string &name) const
CLI::App * addSection(const std::string &name, const std::string &description)
const std::string & getInstanceName() const

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

109 {
110 section->disabled(false);
111
112 CLI::Option* opt = section //
113 ->add_flag(name, description)
114 ->type_name(typeName);
115 if (opt->get_configurable()) {
116 opt->group(section->get_formatter()->get_label("Persistent Options"));
117 }
118
119 return opt;
120 }

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

125 {
126 return addFlag(name, description, typeName) //
127 ->check(additionalValidator);
128 }
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName)

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

64 {
65 return addFlag(name, description, typeName) //
66 ->default_val(defaultValue);
67 }

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

74 {
75 return addFlag(name, description, typeName, defaultValue) //
76 ->check(additionalValidator);
77 }

◆ 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 )

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

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

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

153 {
154 return addFlagFunction(name, callback, description, typeName, defaultValue) //
155 ->check(validator);
156 }
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue)

◆ addOption() [1/7]

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

Definition at line 81 of file ConfigSection.cpp.

81 {
82 if (!instance->getInstanceName().empty() && !section->get_display_name().empty()) {
83 section->disabled(false);
84 }
85
86 CLI::Option* opt = section //
87 ->add_option(name, description);
88
89 if (opt->get_configurable()) {
90 opt->group(section->get_formatter()->get_label("Persistent Options"));
91 }
92
93 return opt;
94 }

◆ addOption() [2/7]

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

Definition at line 96 of file ConfigSection.cpp.

96 {
97 return addOption(name, description) //
98 ->type_name(typeName);
99 }
CLI::Option * addOption(const std::string &name, const std::string &description)

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

104 {
105 return addOption(name, description, typeName) //
106 ->check(additionalValidator);
107 }

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

47 {
48 return addOption(name, description, typeName) //
49 ->default_val(defaultValue);
50 }

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

57 {
58 return addOption(name, description, typeName, defaultValue) //
59 ->check(additionalValidator);
60 }

◆ 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 )

◆ 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 )

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

77 {
78 return requiredCount > 0;
79 }

◆ required() [2/2]

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

Definition at line 60 of file ConfigSection.cpp.

60 {
61 if (req != opt->get_required()) {
62 if (req) {
64 section->needs(opt);
65 opt->default_str("");
66 } else {
68 section->remove_needs(opt);
69 }
70
71 opt->required(req);
72
74 }
75 }
void required(CLI::App *section, bool req=true)

Member Data Documentation

◆ instance

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

Definition at line 111 of file ConfigSection.h.

◆ requiredCount

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

Definition at line 113 of file ConfigSection.h.

◆ section

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

Definition at line 108 of file ConfigSection.h.


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