diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2018-06-04 12:44:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-04 12:44:57 +0200 |
| commit | 8074192a85557feaf84d4aaab9ab42b02464220b (patch) | |
| tree | 397fdd6af48ef94001e5df65102495ea4b89139d /Source/Core/Common/StringUtil.cpp | |
| parent | 472e0d55b807c7a5be847f113109ee4b38b48e80 (diff) | |
| parent | 7154bfd82559747681313531b5d53ab44bd88493 (diff) | |
Merge pull request #7057 from leoetlino/string
Config/StringUtil/IniFile: Get rid of some duplicated code
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index cc1ffaa949..c2a5a62b2d 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,7 +292,42 @@ 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"; } |
