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.h | |
| 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.h')
| -rw-r--r-- | Source/Core/Common/StringUtil.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 2e6089ef14..11c873bdae 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -9,6 +9,7 @@ #include <iomanip> #include <sstream> #include <string> +#include <type_traits> #include <vector> #include "Common/CommonTypes.h" @@ -41,8 +42,6 @@ std::string ArrayToString(const u8* data, u32 size, int line_len = 20, bool spac std::string StripSpaces(const std::string& s); std::string StripQuotes(const std::string& s); -std::string StringFromBool(bool value); - bool TryParse(const std::string& str, bool* output); bool TryParse(const std::string& str, u16* output); bool TryParse(const std::string& str, u32* output); @@ -83,6 +82,20 @@ bool TryParseVector(const std::string& str, std::vector<N>* output, const char d return true; } +std::string ValueToString(u16 value); +std::string ValueToString(u32 value); +std::string ValueToString(u64 value); +std::string ValueToString(float value); +std::string ValueToString(double value); +std::string ValueToString(int value); +std::string ValueToString(s64 value); +std::string ValueToString(bool value); +template <typename T, std::enable_if_t<std::is_enum<T>::value>* = nullptr> +std::string ValueToString(T value) +{ + return ValueToString(static_cast<std::underlying_type_t<T>>(value)); +} + // Generates an hexdump-like representation of a binary data blob. std::string HexDump(const u8* data, size_t size); |
