From 1cc6e51838fcd5fc986dbb3e13bbb85f11a348be Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 24 Jan 2022 17:52:47 +0800 Subject: ... --- src/ui/mapper/style/AndConditionMapper.cpp | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/ui/mapper/style/AndConditionMapper.cpp (limited to 'src/ui/mapper/style/AndConditionMapper.cpp') diff --git a/src/ui/mapper/style/AndConditionMapper.cpp b/src/ui/mapper/style/AndConditionMapper.cpp new file mode 100644 index 00000000..e07e514c --- /dev/null +++ b/src/ui/mapper/style/AndConditionMapper.cpp @@ -0,0 +1,31 @@ +#include "cru/ui/mapper/style/AndConditionMapper.hpp" +#include "cru/common/ClonablePtr.hpp" +#include "cru/ui/mapper/MapperRegistry.hpp" +#include "cru/ui/mapper/style/IConditionMapper.hpp" +#include "cru/ui/style/Condition.hpp" +#include "cru/xml/XmlNode.hpp" + +namespace cru::ui::mapper::style { +bool AndConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode *node) { + return node->GetTag().CaseInsensitiveEqual(u"AndCondition"); +} + +ClonablePtr AndConditionMapper::DoMapFromXml( + xml::XmlElementNode *node) { + std::vector> conditions; + auto condition_mappers = + MapperRegistry::GetInstance()->GetMappersByInterface(); + for (auto child : node->GetChildren()) { + if (child->GetType() == xml::XmlNode::Type::Element) { + auto c = child->AsElement(); + for (auto mapper : condition_mappers) { + if (mapper->XmlElementIsOfThisType(c)) { + conditions.push_back(mapper->MapConditionFromXml(c)); + break; + } + } + } + } + return ui::style::AndCondition::Create(std::move(conditions)); +} +} // namespace cru::ui::mapper::style -- cgit v1.2.3