2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "net/config/ConfigInstance.h"
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
46#include "utils/Config.h"
53#pragma GCC diagnostic push
54#pragma GCC diagnostic ignored "-Wfloat-equal"
56#if __has_warning
("-Wweak-vtables")
57#pragma GCC diagnostic ignored "-Wweak-vtables"
59#if __has_warning
("-Wcovered-switch-default")
60#pragma GCC diagnostic ignored "-Wcovered-switch-default"
64#include "utils/CLI11.hpp"
66#pragma GCC diagnostic pop
71namespace net::config {
78 instanceSc = utils::Config::addInstance(instanceName,
79 std::string(
"Configuration for ")
81 .append(
" instance '")
92 "Disable this instance")
93 ->multi_option_policy(
CLI::MultiOptionPolicy::TakeLast)
95 ->default_str(
"false")
97 ->check(
CLI::IsMember({
"true",
"false"}))
98 ->group(
instanceSc->get_formatter()->get_label(
"Persistent Options"));
119 ->add_subcommand(name, description)
121 ->configurable(
false)
122 ->allow_extras(
false)
129 ->configurable(!sectionSc->get_disabled());
131 if (!sectionSc->get_disabled()) {
132 utils::Config::addStandardFlags(sectionSc);
133 utils::Config::addSimpleHelp(sectionSc);
140 if (req != section->get_required()) {
148 ->remove_needs(section);
167 CLI::App* resultSc = (
instanceSc->got_subcommand(name) || !onlyGot) ?
instanceSc->get_subcommand_no_throw(name) :
nullptr;
169 if (resultSc ==
nullptr && recursive) {
172 (parentSc !=
nullptr && (parentSc->got_subcommand(name) || !onlyGot)) ? parentSc->get_subcommand_no_throw(name) :
nullptr;
180 ->got_subcommand(name) ||
181 (recursive &&
instanceSc->get_parent()->got_subcommand(name));
191 ->default_str(disabled ?
"true" :
"false")
194 utils::Config::disabled(
instanceSc, disabled);
CLI::App * addSection(const std::string &name, const std::string &description, const std::string &group="Sections")
CLI::App * getSection(const std::string &name, bool onlyGot=false, bool recursive=false) const
virtual ~ConfigInstance()
void setDisabled(bool disabled=true)
void setInstanceName(const std::string &instanceName)
ConfigInstance(const std::string &instanceName, Role role)
static const std::string nameAnonymous
const std::string & getInstanceName() const
bool gotSection(const std::string &name, bool recursive=false) const
void required(CLI::App *section, bool req=true)