feat: add support of true list and false list to boolean element

This commit is contained in:
august-alt 2023-10-12 15:25:29 +04:00
parent 29541939a2
commit 26e309f4d1
2 changed files with 81 additions and 0 deletions

View File

@ -22,19 +22,42 @@
#define GPUI_POLICYboolELEMENT_H
#include "policyelement.h"
#include "policyenumelement.h"
#include <any>
#include <string>
namespace model
{
namespace admx
{
// TODO: Add key to vector of true list.
/*!
* \brief A choice element in a policy with associated values for the true and false cases.
*/
class PolicyBoolElement : public PolicyElement
{
public:
/*!
* \brief trueValue Value associated with true.
*/
std::unique_ptr<EnumValue> trueValue {};
/*!
* \brief falseValue Value associated with false.
*/
std::unique_ptr<EnumValue> falseValue {};
/*!
* \brief trueList List of values assicated with true.
*/
std::vector<std::pair<std::string, std::unique_ptr<EnumValue>>> trueList {};
/*!
* \brief trueList List of values assicated with false.
*/
std::vector<std::pair<std::string, std::unique_ptr<EnumValue>>> falseList {};
registry::RegistryEntryType getRegistryEntryType() const override { return registry::REG_DWORD; }
};
} // namespace admx

View File

@ -239,6 +239,36 @@ public:
}
};
void handle_boolean_element(std::unique_ptr<model::admx::EnumValue>& in,
const ::GroupPolicy::PolicyDefinitions::Value& out)
{
if (out.decimal().present())
{
in = std::make_unique<model::admx::DecimalValue>(out.decimal()->value());
}
if (out.longDecimal().present())
{
in = std::make_unique<model::admx::LongDecimalValue>(out.longDecimal()->value());
}
if (out.string().present())
{
in = std::make_unique<model::admx::StringValue>(out.string().get());
}
}
void handle_boolean_element(std::unique_ptr<model::admx::EnumValue>& in,
const ::xsd::cxx::tree::optional<::GroupPolicy::PolicyDefinitions::Value>& out)
{
if (!out.present())
{
return;
}
handle_boolean_element(in, *out);
}
class XsdBooleanElementAdapter : public model::admx::PolicyBoolElement
{
private:
@ -250,6 +280,34 @@ public:
adapter_base(this, element);
assign_if_exists(this->valueName, element.valueName());
handle_boolean_element(this->trueValue, element.trueValue());
handle_boolean_element(this->falseValue, element.falseValue());
if (element.trueList().present())
{
for (auto &listElement : element.trueList()->item())
{
std::unique_ptr<model::admx::EnumValue> in;
handle_boolean_element(in, listElement.value());
this->trueList.emplace_back(listElement.valueName(), std::move(in));
}
}
if (element.falseList().present())
{
for (auto &listElement : element.falseList()->item())
{
std::unique_ptr<model::admx::EnumValue> in;
handle_boolean_element(in, listElement.value());
this->falseList.emplace_back(listElement.valueName(), std::move(in));
}
}
}
static std::unique_ptr<model::admx::PolicyBoolElement> create(const BooleanElement &element)