mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Support StringMap configuration settings.
Allows Configuration values that are space-separated key=value pairs.
This commit is contained in:
parent
83fec38fc9
commit
a439e9488d
1 changed files with 21 additions and 0 deletions
|
@ -268,6 +268,26 @@ template<> std::string BaseSetting<StringSet>::to_string() const
|
||||||
return concatStringsSep(" ", value);
|
return concatStringsSep(" ", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> void BaseSetting<StringMap>::set(const std::string & str)
|
||||||
|
{
|
||||||
|
auto kvpairs = tokenizeString<Strings>(str);
|
||||||
|
for (auto & s : kvpairs)
|
||||||
|
{
|
||||||
|
auto eq = s.find_first_of('=');
|
||||||
|
if (std::string::npos != eq)
|
||||||
|
value.emplace(std::string(s, 0, eq), std::string(s, eq + 1));
|
||||||
|
// else ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> std::string BaseSetting<StringMap>::to_string() const
|
||||||
|
{
|
||||||
|
Strings kvstrs;
|
||||||
|
std::transform(value.begin(), value.end(), back_inserter(kvstrs),
|
||||||
|
[&](auto kvpair){ return kvpair.first + "=" + kvpair.second; });
|
||||||
|
return concatStringsSep(" ", kvstrs);
|
||||||
|
}
|
||||||
|
|
||||||
template class BaseSetting<int>;
|
template class BaseSetting<int>;
|
||||||
template class BaseSetting<unsigned int>;
|
template class BaseSetting<unsigned int>;
|
||||||
template class BaseSetting<long>;
|
template class BaseSetting<long>;
|
||||||
|
@ -278,6 +298,7 @@ template class BaseSetting<bool>;
|
||||||
template class BaseSetting<std::string>;
|
template class BaseSetting<std::string>;
|
||||||
template class BaseSetting<Strings>;
|
template class BaseSetting<Strings>;
|
||||||
template class BaseSetting<StringSet>;
|
template class BaseSetting<StringSet>;
|
||||||
|
template class BaseSetting<StringMap>;
|
||||||
|
|
||||||
void PathSetting::set(const std::string & str)
|
void PathSetting::set(const std::string & str)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue