27 static constexpr bool appendable =
true;
33 static constexpr bool appendable =
true;
39 static constexpr bool appendable =
true;
43struct BaseSetting<std::set<ExperimentalFeature>>::trait
45 static constexpr bool appendable =
true;
51 static constexpr bool appendable =
false;
57 return trait::appendable;
72 static_assert(!trait::appendable,
"using default `appendOrSet` implementation with an appendable type");
75 value = std::move(newValue);
81 if (experimentalFeatureSettings.isEnabled(experimentalFeature))
84 assert(experimentalFeature);
86 "Ignoring setting '%s' because experimental feature '%s' is not enabled",
88 showExperimentalFeature(*experimentalFeature));
93void BaseSetting<bool>::convertToArg(
Args & args,
const std::string & category);
96void BaseSetting<T>::convertToArg(
Args & args,
const std::string & category)
101 .description =
fmt(
"Set the `%s` setting.", name),
102 .category = category,
104 .handler = {[
this](std::string s) {
108 .experimentalFeature = experimentalFeature,
113 .longName =
"extra-" + name,
115 .description =
fmt(
"Append to the `%s` setting.", name),
116 .category = category,
118 .handler = {[
this](std::string s) {
122 .experimentalFeature = experimentalFeature,
126NIX_DECLARE_CONFIG_SERIALISER(std::string)
127NIX_DECLARE_CONFIG_SERIALISER(std::optional<std::string>)
128NIX_DECLARE_CONFIG_SERIALISER(
bool)
129NIX_DECLARE_CONFIG_SERIALISER(Strings)
132NIX_DECLARE_CONFIG_SERIALISER(std::set<ExperimentalFeature>)
133NIX_DECLARE_CONFIG_SERIALISER(std::filesystem::path)
135NIX_DECLARE_CONFIG_SERIALISER(std::set<std::filesystem::path>)
136NIX_DECLARE_CONFIG_SERIALISER(std::optional<AbsolutePath>)
141 static_assert(std::is_integral<T>::value,
"Integer required.");
146 throw UsageError(
"setting '%s' has invalid value '%s'", name, str);
151std::string BaseSetting<T>::to_string()
const
153 static_assert(std::is_integral<T>::value,
"Integer required.");
155 return std::to_string(value);
Definition configuration.hh:339
bool isAppendable() override final
Definition config-impl.hh:55
virtual T parse(const std::string &str) const
Definition config-impl.hh:139
void set(const std::string &str, bool append=false) override final
Definition config-impl.hh:79
virtual void appendOrSet(T newValue, bool append)
Definition config-impl.hh:70
std::string fmt(const std::string &s)
Definition fmt.hh:67
void warn(const std::string &fs, const Args &... args)
Definition logging.hh:388
Definition configuration.hh:242
std::map< std::string, std::string, std::less<> > StringMap
Definition types.hh:26
std::set< std::string, std::less<> > StringSet
Definition types.hh:45
N string2IntWithUnitPrefix(std::string_view s)
Definition util.hh:111