locale independent util::parse_double

This commit is contained in:
MihailRis
2024-02-02 20:02:30 +03:00
parent 84e8fd1af6
commit bc72742ee3
20 changed files with 140 additions and 48 deletions
+2 -7
View File
@@ -25,12 +25,7 @@ int64_t Attribute::asInt() const {
}
double Attribute::asFloat() const {
double value;
auto res = std::from_chars(text.data(), text.data()+text.size(), value);
if (res.ptr != text.data()+text.size()) {
throw std::runtime_error("invalid number format "+escape_string(text));
}
return value;
return util::parse_double(text);
}
bool Attribute::asBool() const {
@@ -45,7 +40,7 @@ void Node::add(xmlelement element) {
}
void Node::set(std::string name, std::string text) {
attrs.insert_or_assign(name, Attribute(name, text));
attrs[name] = Attribute(name, text);
}
const std::string& Node::getTag() const {