Add a way to set multiple parent profiles

This commit is contained in:
Mikhail f. Shiryaev 2019-12-22 15:35:38 +01:00
parent 8711f98c30
commit a940a25684
No known key found for this signature in database
GPG Key ID: 39CD5753BD5D856F
2 changed files with 12 additions and 4 deletions

View File

@ -217,9 +217,17 @@ const SettingsConstraints::Constraint * SettingsConstraints::tryGetConstraint(si
void SettingsConstraints::setProfile(const String & profile_name, const Poco::Util::AbstractConfiguration & config)
{
String parent_profile = "profiles." + profile_name + ".profile";
if (config.has(parent_profile))
setProfile(parent_profile, config); // Inheritance of one profile from another.
String elem = "profiles." + profile_name;
Poco::Util::AbstractConfiguration::Keys config_keys;
config.keys(elem, config_keys);
for (const std::string & key : config_keys)
{
if (key == "profile" || key.find("profile[") == 0) /// Inheritance of profiles from the current one.
setProfile(config.getString(elem + "." + key), config);
else continue;
}
String path_to_constraints = "profiles." + profile_name + ".constraints";
if (config.has(path_to_constraints))

View File

@ -37,7 +37,7 @@ void Settings::setProfile(const String & profile_name, const Poco::Util::Abstrac
{
if (key == "constraints")
continue;
if (key == "profile") /// Inheritance of one profile from another.
if (key == "profile" || key.find("profile[") == 0) /// Inheritance of profiles from the current one.
setProfile(config.getString(elem + "." + key), config);
else
set(key, config.getString(elem + "." + key));