summaryrefslogtreecommitdiff
path: root/Source/Core/Common/StringUtil.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-06-03 14:10:52 +0200
committerLéo Lam <leo@innovatetechnologi.es>2018-06-03 14:10:52 +0200
commitfc0193c4b108d9a914b841829b1c0f0306b609b9 (patch)
treeb10582de815c226aba56cd1ec72c18dc260af680 /Source/Core/Common/StringUtil.cpp
parent66ee47c4179c2948dfa107df852fdb709cedf7b4 (diff)
Move Config ValueToString to StringUtil
An identical implementation is used by IniFile, so move those functions to StringUtil. A future commit will modify IniFile to use them.
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
-rw-r--r--Source/Core/Common/StringUtil.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp
index cc1ffaa949..372ea06c19 100644
--- a/Source/Core/Common/StringUtil.cpp
+++ b/Source/Core/Common/StringUtil.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
+#include <cinttypes>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
@@ -291,11 +292,51 @@ bool TryParse(const std::string& str, bool* const output)
return true;
}
-std::string StringFromBool(bool value)
+std::string ValueToString(u16 value)
+{
+ return StringFromFormat("0x%04x", value);
+}
+
+std::string ValueToString(u32 value)
+{
+ return StringFromFormat("0x%08x", value);
+}
+
+std::string ValueToString(u64 value)
+{
+ return StringFromFormat("0x%016" PRIx64, value);
+}
+
+std::string ValueToString(float value)
+{
+ return StringFromFormat("%#.9g", value);
+}
+
+std::string ValueToString(double value)
+{
+ return StringFromFormat("%#.17g", value);
+}
+
+std::string ValueToString(int value)
+{
+ return std::to_string(value);
+}
+
+std::string ValueToString(s64 value)
+{
+ return StringFromFormat("%" PRId64, value);
+}
+
+std::string ValueToString(bool value)
{
return value ? "True" : "False";
}
+std::string ValueToString(const std::string& value)
+{
+ return value;
+}
+
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename,
std::string* _pExtension)
{