aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/style/HoverConditionMapper.cpp
blob: 97767b140ed336b4af5b1906f4fa6897d4747bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "cru/ui/mapper/style/HoverConditionMapper.h"
#include "cru/common/ClonablePtr.h"
#include "cru/ui/style/Condition.h"

namespace cru::ui::mapper::style {
using namespace cru::ui::style;

bool HoverConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
  return node->GetTag().CaseInsensitiveEqual(u"HoverCondition");
}

ClonablePtr<HoverCondition> HoverConditionMapper::DoMapFromXml(
    xml::XmlElementNode* node) {
  auto value = node->GetAttributeValueCaseInsensitive(u"value");
  if (value.CaseInsensitiveEqual(u"true")) {
    return ui::style::HoverCondition::Create(true);
  } else if (value.CaseInsensitiveEqual(u"false")) {
    return ui::style::HoverCondition::Create(false);
  } else {
    throw Exception(u"Invalid value for HoverCondition: " + value);
  }
}
}  // namespace cru::ui::mapper::style