blob: 4b0104d0c5fa25c7bf98ad8100e15209d49bf852 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "cru/ui/mapper/PointMapper.h"
namespace cru::ui::mapper {
bool PointMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
return node->GetTag().CaseInsensitiveCompare(u"Point") == 0;
}
Point PointMapper::DoMapFromString(String str) {
std::vector<float> values = str.ParseToFloatList();
if (values.size() == 2) {
return {values[0], values[1]};
} else if (values.size() == 1) {
return {values[0], values[0]};
} else {
throw Exception(u"Invalid Point string.");
}
}
Point PointMapper::DoMapFromXml(xml::XmlElementNode* node) {
auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
if (!value_attr) return {};
return DoMapFromString(*value_attr);
}
} // namespace cru::ui::mapper
|