mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-07-17 19:56:38 -04:00
added float parse support .
This commit is contained in:
parent
d4a58864ff
commit
7d80e89afb
3 changed files with 112 additions and 77 deletions
|
@ -28,6 +28,21 @@ public:
|
|||
}
|
||||
return def;
|
||||
}
|
||||
static double StringToDouble(const CString& str, double def)
|
||||
{
|
||||
double ret = 0;
|
||||
if (sscanf_s(str, "%lf", &ret) == 1) {
|
||||
if (strchr(str, '%')) {
|
||||
ret *= 0.01;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
static float StringToFloat(const CString& str, float def)
|
||||
{
|
||||
return static_cast<float>(StringToDouble(str, def));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static CString ToString(const T& origin);// { static_assert(false, "T must have specialized implementations!"); }
|
||||
|
@ -38,4 +53,12 @@ public:
|
|||
static CString result[] = { "no", "yes" };
|
||||
return result[origin];
|
||||
}
|
||||
|
||||
template<>
|
||||
static CString ToString<int>(const int& origin)
|
||||
{
|
||||
char buffer[0x100];
|
||||
_itoa_s(origin, buffer, 10);
|
||||
return buffer;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue