diff options
| author | 2016-09-18 09:38:01 +0900 | |
|---|---|---|
| committer | 2016-09-18 09:38:01 +0900 | |
| commit | dc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch) | |
| tree | 569a7f13128450bbab973236615587ff00bced5f /src/common/string_util.h | |
| parent | Travis: Import Dolphin’s clang-format hook. (diff) | |
| download | yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip | |
Sources: Run clang-format on everything.
Diffstat (limited to 'src/common/string_util.h')
| -rw-r--r-- | src/common/string_util.h | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h index 89d9f133e..6ffd735f4 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -25,9 +25,8 @@ std::string StringFromFormat(const char* format, ...); | |||
| 25 | // Cheap! | 25 | // Cheap! |
| 26 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); | 26 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); |
| 27 | 27 | ||
| 28 | template<size_t Count> | 28 | template <size_t Count> |
| 29 | inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...) | 29 | inline void CharArrayFromFormat(char (&out)[Count], const char* format, ...) { |
| 30 | { | ||
| 31 | va_list args; | 30 | va_list args; |
| 32 | va_start(args, format); | 31 | va_start(args, format); |
| 33 | CharArrayFromFormatV(out, Count, format, args); | 32 | CharArrayFromFormatV(out, Count, format, args); |
| @@ -35,15 +34,14 @@ inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...) | |||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | // Good | 36 | // Good |
| 38 | std::string ArrayToString(const u8 *data, u32 size, int line_len = 20, bool spaces = true); | 37 | std::string ArrayToString(const u8* data, u32 size, int line_len = 20, bool spaces = true); |
| 39 | 38 | ||
| 40 | std::string StripSpaces(const std::string &s); | 39 | std::string StripSpaces(const std::string& s); |
| 41 | std::string StripQuotes(const std::string &s); | 40 | std::string StripQuotes(const std::string& s); |
| 42 | 41 | ||
| 43 | // Thousand separator. Turns 12345678 into 12,345,678 | 42 | // Thousand separator. Turns 12345678 into 12,345,678 |
| 44 | template <typename I> | 43 | template <typename I> |
| 45 | std::string ThousandSeparate(I value, int spaces = 0) | 44 | std::string ThousandSeparate(I value, int spaces = 0) { |
| 46 | { | ||
| 47 | std::ostringstream oss; | 45 | std::ostringstream oss; |
| 48 | 46 | ||
| 49 | // std::locale("") seems to be broken on many platforms | 47 | // std::locale("") seems to be broken on many platforms |
| @@ -57,35 +55,34 @@ std::string ThousandSeparate(I value, int spaces = 0) | |||
| 57 | 55 | ||
| 58 | std::string StringFromBool(bool value); | 56 | std::string StringFromBool(bool value); |
| 59 | 57 | ||
| 60 | bool TryParse(const std::string &str, bool *output); | 58 | bool TryParse(const std::string& str, bool* output); |
| 61 | bool TryParse(const std::string &str, u32 *output); | 59 | bool TryParse(const std::string& str, u32* output); |
| 62 | 60 | ||
| 63 | template <typename N> | 61 | template <typename N> |
| 64 | static bool TryParse(const std::string &str, N *const output) | 62 | static bool TryParse(const std::string& str, N* const output) { |
| 65 | { | ||
| 66 | std::istringstream iss(str); | 63 | std::istringstream iss(str); |
| 67 | 64 | ||
| 68 | N tmp = 0; | 65 | N tmp = 0; |
| 69 | if (iss >> tmp) | 66 | if (iss >> tmp) { |
| 70 | { | ||
| 71 | *output = tmp; | 67 | *output = tmp; |
| 72 | return true; | 68 | return true; |
| 73 | } | 69 | } else |
| 74 | else | ||
| 75 | return false; | 70 | return false; |
| 76 | } | 71 | } |
| 77 | 72 | ||
| 78 | // TODO: kill this | 73 | // TODO: kill this |
| 79 | bool AsciiToHex(const char* _szValue, u32& result); | 74 | bool AsciiToHex(const char* _szValue, u32& result); |
| 80 | 75 | ||
| 81 | std::string TabsToSpaces(int tab_size, const std::string &in); | 76 | std::string TabsToSpaces(int tab_size, const std::string& in); |
| 82 | 77 | ||
| 83 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); | 78 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); |
| 84 | 79 | ||
| 85 | // "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe" | 80 | // "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe" |
| 86 | bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, std::string* _pExtension); | 81 | bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, |
| 82 | std::string* _pExtension); | ||
| 87 | 83 | ||
| 88 | void BuildCompleteFilename(std::string& _CompleteFilename, const std::string& _Path, const std::string& _Filename); | 84 | void BuildCompleteFilename(std::string& _CompleteFilename, const std::string& _Path, |
| 85 | const std::string& _Filename); | ||
| 89 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest); | 86 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest); |
| 90 | 87 | ||
| 91 | std::string UTF16ToUTF8(const std::u16string& input); | 88 | std::string UTF16ToUTF8(const std::u16string& input); |
| @@ -99,17 +96,21 @@ std::string UTF16ToUTF8(const std::wstring& input); | |||
| 99 | std::wstring UTF8ToUTF16W(const std::string& str); | 96 | std::wstring UTF8ToUTF16W(const std::string& str); |
| 100 | 97 | ||
| 101 | #ifdef _UNICODE | 98 | #ifdef _UNICODE |
| 102 | inline std::string TStrToUTF8(const std::wstring& str) | 99 | inline std::string TStrToUTF8(const std::wstring& str) { |
| 103 | { return UTF16ToUTF8(str); } | 100 | return UTF16ToUTF8(str); |
| 101 | } | ||
| 104 | 102 | ||
| 105 | inline std::wstring UTF8ToTStr(const std::string& str) | 103 | inline std::wstring UTF8ToTStr(const std::string& str) { |
| 106 | { return UTF8ToUTF16W(str); } | 104 | return UTF8ToUTF16W(str); |
| 105 | } | ||
| 107 | #else | 106 | #else |
| 108 | inline std::string TStrToUTF8(const std::string& str) | 107 | inline std::string TStrToUTF8(const std::string& str) { |
| 109 | { return str; } | 108 | return str; |
| 109 | } | ||
| 110 | 110 | ||
| 111 | inline std::string UTF8ToTStr(const std::string& str) | 111 | inline std::string UTF8ToTStr(const std::string& str) { |
| 112 | { return str; } | 112 | return str; |
| 113 | } | ||
| 113 | #endif | 114 | #endif |
| 114 | 115 | ||
| 115 | #endif | 116 | #endif |
| @@ -134,5 +135,4 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) { | |||
| 134 | * NUL-terminated then the string ends at max_len characters. | 135 | * NUL-terminated then the string ends at max_len characters. |
| 135 | */ | 136 | */ |
| 136 | std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len); | 137 | std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len); |
| 137 | |||
| 138 | } | 138 | } |