mirror of https://github.com/stella-emu/stella.git
Parse strings and float in the same locale in which they were serializwd.
This commit is contained in:
parent
b40a614cee
commit
098a2a5fb1
|
@ -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); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue