mirror of
https://github.com/NixOS/nix
synced 2025-06-30 11:43:15 +02:00
Merge remote-tracking branch 'origin/master' into flakes
This commit is contained in:
commit
87873d0d65
25 changed files with 128 additions and 93 deletions
|
@ -154,6 +154,11 @@ AbstractSetting::AbstractSetting(
|
|||
{
|
||||
}
|
||||
|
||||
void AbstractSetting::setDefault(const std::string & str)
|
||||
{
|
||||
if (!overriden) set(str);
|
||||
}
|
||||
|
||||
void AbstractSetting::toJSON(JSONPlaceholder & out)
|
||||
{
|
||||
out.write(to_string());
|
||||
|
@ -185,7 +190,7 @@ template<> void BaseSetting<std::string>::set(const std::string & str)
|
|||
value = str;
|
||||
}
|
||||
|
||||
template<> std::string BaseSetting<std::string>::to_string()
|
||||
template<> std::string BaseSetting<std::string>::to_string() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
@ -199,7 +204,7 @@ void BaseSetting<T>::set(const std::string & str)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
std::string BaseSetting<T>::to_string()
|
||||
std::string BaseSetting<T>::to_string() const
|
||||
{
|
||||
static_assert(std::is_integral<T>::value, "Integer required.");
|
||||
return std::to_string(value);
|
||||
|
@ -215,7 +220,7 @@ template<> void BaseSetting<bool>::set(const std::string & str)
|
|||
throw UsageError("Boolean setting '%s' has invalid value '%s'", name, str);
|
||||
}
|
||||
|
||||
template<> std::string BaseSetting<bool>::to_string()
|
||||
template<> std::string BaseSetting<bool>::to_string() const
|
||||
{
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
|
@ -239,7 +244,7 @@ template<> void BaseSetting<Strings>::set(const std::string & str)
|
|||
value = tokenizeString<Strings>(str);
|
||||
}
|
||||
|
||||
template<> std::string BaseSetting<Strings>::to_string()
|
||||
template<> std::string BaseSetting<Strings>::to_string() const
|
||||
{
|
||||
return concatStringsSep(" ", value);
|
||||
}
|
||||
|
@ -256,7 +261,7 @@ template<> void BaseSetting<StringSet>::set(const std::string & str)
|
|||
value = tokenizeString<StringSet>(str);
|
||||
}
|
||||
|
||||
template<> std::string BaseSetting<StringSet>::to_string()
|
||||
template<> std::string BaseSetting<StringSet>::to_string() const
|
||||
{
|
||||
return concatStringsSep(" ", value);
|
||||
}
|
||||
|
|
|
@ -115,6 +115,8 @@ public:
|
|||
|
||||
bool overriden = false;
|
||||
|
||||
void setDefault(const std::string & str);
|
||||
|
||||
protected:
|
||||
|
||||
AbstractSetting(
|
||||
|
@ -131,13 +133,13 @@ protected:
|
|||
|
||||
virtual void set(const std::string & value) = 0;
|
||||
|
||||
virtual std::string to_string() = 0;
|
||||
virtual std::string to_string() const = 0;
|
||||
|
||||
virtual void toJSON(JSONPlaceholder & out);
|
||||
|
||||
virtual void convertToArg(Args & args, const std::string & category);
|
||||
|
||||
bool isOverriden() { return overriden; }
|
||||
bool isOverriden() const { return overriden; }
|
||||
};
|
||||
|
||||
/* A setting of type T. */
|
||||
|
@ -174,7 +176,7 @@ public:
|
|||
value = v;
|
||||
}
|
||||
|
||||
std::string to_string() override;
|
||||
std::string to_string() const override;
|
||||
|
||||
void convertToArg(Args & args, const std::string & category) override;
|
||||
|
||||
|
|
|
@ -1213,7 +1213,7 @@ void _interrupted()
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template<class C> C tokenizeString(const string & s, const string & separators)
|
||||
template<class C> C tokenizeString(std::string_view s, const string & separators)
|
||||
{
|
||||
C result;
|
||||
string::size_type pos = s.find_first_not_of(separators, 0);
|
||||
|
@ -1227,9 +1227,9 @@ template<class C> C tokenizeString(const string & s, const string & separators)
|
|||
return result;
|
||||
}
|
||||
|
||||
template Strings tokenizeString(const string & s, const string & separators);
|
||||
template StringSet tokenizeString(const string & s, const string & separators);
|
||||
template vector<string> tokenizeString(const string & s, const string & separators);
|
||||
template Strings tokenizeString(std::string_view s, const string & separators);
|
||||
template StringSet tokenizeString(std::string_view s, const string & separators);
|
||||
template vector<string> tokenizeString(std::string_view s, const string & separators);
|
||||
|
||||
|
||||
string chomp(const string & s)
|
||||
|
|
|
@ -346,7 +346,7 @@ MakeError(FormatError, Error);
|
|||
|
||||
|
||||
/* String tokenizer. */
|
||||
template<class C> C tokenizeString(const string & s, const string & separators = " \t\n\r");
|
||||
template<class C> C tokenizeString(std::string_view s, const string & separators = " \t\n\r");
|
||||
|
||||
|
||||
/* Concatenate the given strings with a separator between the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue