mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-14 12:58:39 +03:00
fix: AbstractRegistrySource
and PolRegistrySource
This commit is contained in:
parent
e2f160e7ce
commit
4e49199a00
@ -48,8 +48,12 @@ public:
|
||||
virtual void markValueForDeletion(const std::string &key, const std::string &valueName) = 0;
|
||||
virtual bool undeleteValue(const std::string &key, const std::string &valueName) = 0;
|
||||
virtual bool isValueMarkedForDeletion(const std::string &key, const std::string &valueName) const = 0;
|
||||
|
||||
virtual std::vector<std::string> getNonSpecialValueNames(const std::string &key) const = 0;
|
||||
virtual std::vector<std::string> getValueNames(const std::string &key) const = 0;
|
||||
|
||||
virtual void markValueNamesInKeyForDeletion(const std::string &key) = 0;
|
||||
|
||||
virtual std::vector<std::string> getValueNames(const std::string &key) const = 0;
|
||||
virtual void clearKey(const std::string &key) = 0;
|
||||
virtual void clearValue(const std::string &key, const std::string &valueName) = 0;
|
||||
|
||||
|
@ -207,7 +207,30 @@ std::vector<std::string> PolRegistrySource::getValueNames(const std::string &key
|
||||
return result;
|
||||
}
|
||||
|
||||
void PolRegistrySource::clearKey(const std::string &key)
|
||||
static bool isSpecialValueName(const std::string &str)
|
||||
{
|
||||
// TODO: make case-insensitive
|
||||
// TODO: check for others
|
||||
return (str == "**deletevalues") ||
|
||||
(str == "**delvals.") ||
|
||||
(str == "**deletekeys") ||
|
||||
(str == "**securekey") ||
|
||||
(str.length() >= 6 && strncmp(str.c_str(), "**del.", 6)) ||
|
||||
(str.length() >= 7 && strncmp(str.c_str(), "**soft.", 7));
|
||||
}
|
||||
|
||||
std::vector<std::string> PolRegistrySource::getNonSpecialValueNames(const std::string &key) const
|
||||
{
|
||||
std::vector<std::string> result = getValueNames(key);
|
||||
|
||||
result.erase(std::remove_if(result.begin(),
|
||||
result.end(),
|
||||
&isSpecialValueName),
|
||||
result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
void PolRegistrySource::markValueNamesInKeyForDeletion(const std::string &key)
|
||||
{
|
||||
std::vector<std::string> values = getValueNames(key);
|
||||
for (const auto &value : values)
|
||||
@ -216,6 +239,15 @@ void PolRegistrySource::clearKey(const std::string &key)
|
||||
}
|
||||
}
|
||||
|
||||
void PolRegistrySource::clearKey(const std::string &key)
|
||||
{
|
||||
std::vector<std::string> values = getValueNames(key);
|
||||
for (const auto &value : values)
|
||||
{
|
||||
clearValue(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
void PolRegistrySource::clearValue(const std::string &key, const std::string &valueName)
|
||||
{
|
||||
auto &entries = d->registry->registryEntries;
|
||||
|
@ -55,7 +55,10 @@ public:
|
||||
bool undeleteValue(const std::string &key, const std::string &valueName) override final;
|
||||
bool isValueMarkedForDeletion(const std::string &key, const std::string &valueName) const override final;
|
||||
|
||||
std::vector<std::string> getNonSpecialValueNames(const std::string &key) const override final;
|
||||
std::vector<std::string> getValueNames(const std::string &key) const override final;
|
||||
void markValueNamesInKeyForDeletion(const std::string &key) override final;
|
||||
|
||||
void clearKey(const std::string &key) override final;
|
||||
void clearValue(const std::string &key, const std::string &valueName) override final;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user