blob: f35e65d22363c57031e1664f107e1b2c5bf8cfb5 (
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/MeasureLengthMapper.h"
#include "cru/base/StringUtil.h"
#include "cru/ui/render/MeasureRequirement.h"
namespace cru::ui::mapper {
render::MeasureLength MeasureLengthMapper::DoMapFromString(std::string str) {
if (cru::string::CaseInsensitiveCompare(str, "notspecified") == 0) {
return render::MeasureLength::NotSpecified();
}
if (cru::string::CaseInsensitiveCompare(str, "unspecified") == 0) {
return render::MeasureLength::NotSpecified();
}
auto value = cru::string::ParseToNumber<float>(str).value;
if (value < 0) {
return render::MeasureLength::NotSpecified();
}
return render::MeasureLength(value);
}
render::MeasureLength MeasureLengthMapper::DoMapFromXml(
xml::XmlElementNode* node) {
return MapFromXmlAsStringValue(node, render::MeasureLength::NotSpecified());
}
} // namespace cru::ui::mapper
|