From fc0193c4b108d9a914b841829b1c0f0306b609b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 3 Jun 2018 14:10:52 +0200 Subject: 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. --- Source/Core/Common/StringUtil.cpp | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common/StringUtil.cpp') 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 +#include #include #include #include @@ -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) { -- cgit v1.2.3 From 83324fe77dced89c6369b75ecf91899078508e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 3 Jun 2018 14:55:39 +0200 Subject: StringUtil: Remove ValueToString(std::string) Doesn't make a lot of sense to have a function that gives the string representation for a string. --- Source/Core/Common/StringUtil.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Source/Core/Common/StringUtil.cpp') diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 372ea06c19..c2a5a62b2d 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -332,11 +332,6 @@ 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) { -- cgit v1.2.3