Parse strings and float in the same locale in which they were serializwd.

This commit is contained in:
Christian Speckner 2018-12-20 23:48:16 +01:00
parent b40a614cee
commit 098a2a5fb1
1 changed files with 14 additions and 2 deletions

View File

@ -57,8 +57,20 @@ class Variant
// Conversion methods // Conversion methods
const string& toString() const { return data; } const string& toString() const { return data; }
const char* const toCString() const { return data.c_str(); } const char* const toCString() const { return data.c_str(); }
const Int32 toInt() const { return atoi(data.c_str()); } const Int32 toInt() const {
const float toFloat() const { return float(atof(data.c_str())); } istringstream ss(data);
Int32 parsed;
ss >> parsed;
return parsed;
}
const float toFloat() const {
istringstream ss(data);
float parsed;
ss >> parsed;
return parsed;
}
const bool toBool() const { return data == "1" || data == "true"; } const bool toBool() const { return data == "1" || data == "true"; }
const GUI::Size toSize() const { return GUI::Size(data); } const GUI::Size toSize() const { return GUI::Size(data); }