summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index b0d3d2e0e3..5165363094 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -244,7 +244,6 @@ bool TryParseInt(const char* str, int* outVal)
return true;
}
-
bool TryParseBool(const char* str, bool* output)
{
if ((str[0] == '1') || !strcasecmp(str, "true"))
@@ -260,6 +259,25 @@ bool TryParseBool(const char* str, bool* output)
return false;
}
+bool TryParseFloat(const char* str, float *output)
+{
+ double d_val;
+ if (sscanf(str, "%f", &d_val) == 1)
+ {
+ *output = (float)d_val;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool TryParseDouble(const char* str, double *output)
+{
+ return sscanf(str, "%f", output) == 1;
+}
+
std::string StringFromInt(int value)
{
char temp[16];