22 static constexpr bool appendable =
true;
26 static constexpr bool appendable =
true;
30 static constexpr bool appendable =
true;
32template<>
struct BaseSetting<std::set<ExperimentalFeature>>::trait
34 static constexpr bool appendable =
true;
40 static constexpr bool appendable =
false;
46 return trait::appendable;
59 "using default `appendOrSet` implementation with an appendable type");
62 value = std::move(newValue);
68 if (experimentalFeatureSettings.isEnabled(experimentalFeature))
71 assert(experimentalFeature);
72 warn(
"Ignoring setting '%s' because experimental feature '%s' is not enabled",
74 showExperimentalFeature(*experimentalFeature));
78template<>
void BaseSetting<bool>::convertToArg(
Args &
args,
const std::string & category);
81void BaseSetting<T>::convertToArg(
Args &
args,
const std::string & category)
86 .description =
fmt(
"Set the `%s` setting.",
name),
89 .handler = {[
this](std::string
s) { overridden =
true;
set(
s); }},
95 .longName =
"extra-" +
name,
97 .description =
fmt(
"Append to the `%s` setting.",
name),
100 .handler = {[
this](std::string
s) { overridden =
true;
set(
s,
true); }},
105#define DECLARE_CONFIG_SERIALISER(TY) \
106 template<> TY BaseSetting< TY >::parse(const std::string & str) const; \
107 template<> std::string BaseSetting< TY >::to_string() const;
109DECLARE_CONFIG_SERIALISER(std::string)
110DECLARE_CONFIG_SERIALISER(std::optional<std::string>)
111DECLARE_CONFIG_SERIALISER(
bool)
112DECLARE_CONFIG_SERIALISER(Strings)
113DECLARE_CONFIG_SERIALISER(StringSet)
114DECLARE_CONFIG_SERIALISER(StringMap)
115DECLARE_CONFIG_SERIALISER(std::set<ExperimentalFeature>)
120 static_assert(std::is_integral<T>::value,
"Integer required.");
125 throw UsageError(
"setting '%s' has invalid value '%s'", name,
str);
130std::string BaseSetting<T>::to_string()
const
132 static_assert(std::is_integral<T>::value,
"Integer required.");
134 return std::to_string(
value);
bool isAppendable() override final
Definition config-impl.hh:44
virtual T parse(const std::string &str) const
Definition config-impl.hh:118
void set(const std::string &str, bool append=false) override final
Definition config-impl.hh:66
virtual void appendOrSet(T newValue, bool append)
Definition config-impl.hh:55
std::string fmt(const std::string &s)
Definition fmt.hh:67
return s
Definition lexer.l:459
std::ostream & str
Definition lexer.l:1728
const std::string_view & name
Definition lexer.l:1709
virtual void appendOrSet(T newValue, bool append)
virtual bool set(const std::string &name, const std::string &value)=0
const T & value
Definition lexer.l:492
std::optional< ExperimentalFeature > experimentalFeature
Definition lexer.l:1937
std::vector< Expr * > args
Definition lexer.l:6126
virtual bool isAppendable()=0
void warn(const std::string &fs, const Args &... args)
Definition logging.hh:255
N string2IntWithUnitPrefix(std::string_view s)
Definition util.hh:88