aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/style/AndConditionMapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/mapper/style/AndConditionMapper.cpp')
-rw-r--r--src/ui/mapper/style/AndConditionMapper.cpp31
1 files changed, 31 insertions, 0 deletions
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<ui::style::AndCondition> AndConditionMapper::DoMapFromXml(
+ xml::XmlElementNode *node) {
+ std::vector<ClonablePtr<ui::style::Condition>> conditions;
+ auto condition_mappers =
+ MapperRegistry::GetInstance()->GetMappersByInterface<IConditionMapper>();
+ 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