24 static constexpr bool appendable =
true;
28 static constexpr bool appendable =
true;
32 static constexpr bool appendable =
true;
34template<>
struct BaseSetting<ExperimentalFeatures>::trait
36 static constexpr bool appendable =
true;
38template<>
struct BaseSetting<DeprecatedFeatures>::trait
40 static constexpr bool appendable =
true;
46 static constexpr bool appendable =
false;
52 return trait::appendable;
66 "using default `appendOrSet` implementation with an appendable type");
68 value = std::move(newValue);
74 if (experimentalFeatureSettings.isEnabled(experimentalFeature)) {
75 auto parsed =
parse(str, options);
76 if (deprecated && (append || parsed != value)) {
77 warn(
"deprecated setting '%s' found (set to '%s')", name, str);
82 assert(experimentalFeature);
83 warn(
"Ignoring setting '%s' because experimental feature '%s' is not enabled",
85 showExperimentalFeature(*experimentalFeature));
90void BaseSetting<T>::override(
const T & v)
96template<>
void BaseSetting<bool>::convertToArg(Args & args,
const std::string & category);
99void BaseSetting<T>::convertToArg(Args & args,
const std::string & category)
103 .description = fmt(
"Set the `%s` setting.", name),
104 .category = category,
106 .handler = {[
this](std::string s) { set(s); }},
107 .experimentalFeature = experimentalFeature,
112 .longName =
"extra-" + name,
113 .description =
fmt(
"Append to the `%s` setting.", name),
114 .category = category,
116 .handler = {[
this](std::string s) { set(s,
true); }},
117 .experimentalFeature = experimentalFeature,
121#define DECLARE_CONFIG_SERIALISER(TY) \
122 template<> TY BaseSetting< TY >::parse(const std::string & str, const ApplyConfigOptions & options) const; \
123 template<> std::string BaseSetting< TY >::to_string() const;
125DECLARE_CONFIG_SERIALISER(std::string)
126DECLARE_CONFIG_SERIALISER(std::optional<std::string>)
127DECLARE_CONFIG_SERIALISER(std::optional<uint16_t>)
128DECLARE_CONFIG_SERIALISER(
bool)
129DECLARE_CONFIG_SERIALISER(Strings)
130DECLARE_CONFIG_SERIALISER(StringSet)
131DECLARE_CONFIG_SERIALISER(StringMap)
132DECLARE_CONFIG_SERIALISER(ExperimentalFeatures)
133DECLARE_CONFIG_SERIALISER(DeprecatedFeatures)
138 static_assert(std::is_integral<T>::value,
"Integer required.");
140 if (
auto n = string2Int<T>(str))
143 throw UsageError(
"setting '%s' has invalid value '%s'", name, str);
147std::string BaseSetting<T>::to_string()
const
149 static_assert(std::is_integral<T>::value,
"Integer required.");
151 return std::to_string(value);
virtual void appendOrSet(T newValue, bool append, const ApplyConfigOptions &options)
Definition config-impl.hh:62
virtual T parse(const std::string &str, const ApplyConfigOptions &options) const
Definition config-impl.hh:136
bool isAppendable() override final
Definition config-impl.hh:50
void set(const std::string &str, bool append=false, const ApplyConfigOptions &options={}) override final
Definition config-impl.hh:72
std::string fmt(const std::string &s)
Definition fmt.hh:127
void warn(const std::string &fs, const Args &... args)
Definition logging.hh:305
Definition apply-config-options.hh:15