diff options
Diffstat (limited to 'src/common/string_util.h')
| -rw-r--r-- | src/common/string_util.h | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h index 32bf6a19c..08f96533b 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -5,8 +5,6 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <iomanip> | ||
| 9 | #include <sstream> | ||
| 10 | #include <string> | 8 | #include <string> |
| 11 | #include <vector> | 9 | #include <vector> |
| 12 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| @@ -19,44 +17,13 @@ std::string ToLower(std::string str); | |||
| 19 | /// Make a string uppercase | 17 | /// Make a string uppercase |
| 20 | std::string ToUpper(std::string str); | 18 | std::string ToUpper(std::string str); |
| 21 | 19 | ||
| 22 | std::string ArrayToString(const u8* data, std::size_t size, int line_len = 20, bool spaces = true); | ||
| 23 | |||
| 24 | std::string StringFromBuffer(const std::vector<u8>& data); | 20 | std::string StringFromBuffer(const std::vector<u8>& data); |
| 25 | 21 | ||
| 26 | std::string StripSpaces(const std::string& s); | 22 | std::string StripSpaces(const std::string& s); |
| 27 | std::string StripQuotes(const std::string& s); | 23 | std::string StripQuotes(const std::string& s); |
| 28 | 24 | ||
| 29 | // Thousand separator. Turns 12345678 into 12,345,678 | ||
| 30 | template <typename I> | ||
| 31 | std::string ThousandSeparate(I value, int spaces = 0) { | ||
| 32 | std::ostringstream oss; | ||
| 33 | |||
| 34 | // std::locale("") seems to be broken on many platforms | ||
| 35 | #if defined _WIN32 || (defined __linux__ && !defined __clang__) | ||
| 36 | oss.imbue(std::locale("")); | ||
| 37 | #endif | ||
| 38 | oss << std::setw(spaces) << value; | ||
| 39 | |||
| 40 | return oss.str(); | ||
| 41 | } | ||
| 42 | |||
| 43 | std::string StringFromBool(bool value); | 25 | std::string StringFromBool(bool value); |
| 44 | 26 | ||
| 45 | bool TryParse(const std::string& str, bool* output); | ||
| 46 | bool TryParse(const std::string& str, u32* output); | ||
| 47 | |||
| 48 | template <typename N> | ||
| 49 | static bool TryParse(const std::string& str, N* const output) { | ||
| 50 | std::istringstream iss(str); | ||
| 51 | |||
| 52 | N tmp = 0; | ||
| 53 | if (iss >> tmp) { | ||
| 54 | *output = tmp; | ||
| 55 | return true; | ||
| 56 | } else | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | |||
| 60 | std::string TabsToSpaces(int tab_size, std::string in); | 27 | std::string TabsToSpaces(int tab_size, std::string in); |
| 61 | 28 | ||
| 62 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); | 29 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); |