Merge "Add PathsSetting" into main
This commit is contained in:
committed by
Gerrit Code Review
commit
8ed8b9aef0
@@ -437,6 +437,34 @@ void OptionalPathSetting::operator =(const std::optional<Path> & v)
|
||||
this->assign(v);
|
||||
}
|
||||
|
||||
PathsSetting::PathsSetting(Config * options,
|
||||
const Paths & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases)
|
||||
: BaseSetting<Paths>(def, true, name, description, aliases)
|
||||
{
|
||||
options->addSetting(this);
|
||||
}
|
||||
|
||||
|
||||
Paths PathsSetting::parse(const std::string & str) const
|
||||
{
|
||||
auto strings = tokenizeString<Strings>(str);
|
||||
Paths parsed;
|
||||
|
||||
for (auto str : strings) {
|
||||
parsed.push_back(canonPath(str));
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
PathsSetting::operator bool() const noexcept
|
||||
{
|
||||
return !get().empty();
|
||||
}
|
||||
|
||||
bool GlobalConfig::set(const std::string & name, const std::string & value)
|
||||
{
|
||||
for (auto & config : *configRegistrations)
|
||||
|
||||
@@ -375,6 +375,26 @@ public:
|
||||
void operator =(const std::optional<Path> & v);
|
||||
};
|
||||
|
||||
/**
|
||||
* Like `OptionalPathSetting`, but allows multiple paths.
|
||||
*/
|
||||
class PathsSetting : public BaseSetting<Paths>
|
||||
{
|
||||
public:
|
||||
|
||||
PathsSetting(Config * options,
|
||||
const Paths & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases = {});
|
||||
|
||||
Paths parse(const std::string & str) const override;
|
||||
|
||||
void operator =(const Paths & v);
|
||||
|
||||
operator bool() const noexcept;
|
||||
};
|
||||
|
||||
struct GlobalConfig : public AbstractConfig
|
||||
{
|
||||
typedef std::vector<Config*> ConfigRegistrations;
|
||||
|
||||
Reference in New Issue
Block a user