SNode.C
Loading...
Searching...
No Matches
ConfigSection.cpp
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "net/config/ConfigSection.h"
21
22#include "net/config/ConfigInstance.h"
23
24#ifndef DOXYGEN_SHOULD_SKIP_THIS
25
26#ifdef __GNUC__
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wfloat-equal"
29#ifdef __has_warning
30#if __has_warning("-Wweak-vtables")
31#pragma GCC diagnostic ignored "-Wweak-vtables"
32#endif
33#if __has_warning("-Wcovered-switch-default")
34#pragma GCC diagnostic ignored "-Wcovered-switch-default"
35#endif
36#endif
37#endif
38#include "utils/CLI11.hpp"
39#ifdef __GNUC__
40#pragma GCC diagnostic pop
41#endif
42
43#include <memory>
44#include <string>
45
46#endif // DOXYGEN_SHOULD_SKIP_THIS
47
48namespace net::config {
49
59
61 if (req != opt->get_required()) {
62 if (req) {
65 opt->default_str("");
66 } else {
69 }
70
72
74 }
75 }
76
77 bool ConfigSection::required() const {
78 return requiredCount > 0;
79 }
80
83 section->disabled(false);
84 }
85
86 CLI::Option* opt = section //
88
89 if (opt->get_configurable()) {
90 opt->group(section->get_formatter()->get_label("Persistent Options"));
91 }
92
93 return opt;
94 }
95
100
108
110 section->disabled(false);
111
112 CLI::Option* opt = section //
115 if (opt->get_configurable()) {
116 opt->group(section->get_formatter()->get_label("Persistent Options"));
117 }
118
119 return opt;
120 }
121
129
131 const std::function<void()>& callback,
132 const std::string& description,
133 const std::string& typeName,
134 const std::string& defaultValue) {
135 section->disabled(false);
136
137 CLI::Option* opt = section //
141 if (opt->get_configurable()) {
142 opt->group(section->get_formatter()->get_label("Persistent Options"));
143 }
144
145 return opt;
146 }
147
149 const std::function<void()>& callback,
150 const std::string& description,
151 const std::string& typeName,
152 const std::string& defaultValue,
153 const CLI::Validator& validator) {
155 ->check(validator);
156 }
157
158} // namespace net::config