diff options
| author | JosJuice <josjuice@gmail.com> | 2026-07-05 17:38:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-05 17:38:09 +0200 |
| commit | 59d7547c2c6ba54adf44ad222fe308ba99947a42 (patch) | |
| tree | 2d8150054052e187c40285d9117f3c18817b5e07 /Source/Core/Common/StringUtil.cpp | |
| parent | 2dfb23267cf27408d0af466f27bc5a99af6ab982 (diff) | |
| parent | 3f5460a5ff318751b3effb85c4c57bbdd46e9ece (diff) | |
Merge pull request #13216 from CelestialAmber/cw-demangler
Core: Implement automatic symbol demangling
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index ed4837b112..e84fabcbb5 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -193,7 +193,7 @@ std::string ArrayToString(const u8* data, u32 size, int line_len, bool spaces) template <typename T> static std::string_view StripEnclosingChars(std::string_view str, T chars) { - const size_t s = str.find_first_not_of(chars); + const std::size_t s = str.find_first_not_of(chars); if (str.npos != s) return str.substr(s, str.find_last_not_of(chars) - s + 1); @@ -201,12 +201,41 @@ static std::string_view StripEnclosingChars(std::string_view str, T chars) return ""; } +template <typename T> +static std::string_view StripLeadingChars(std::string_view str, T chars) +{ + const std::size_t s = str.find_first_not_of(chars); + + if (str.npos != s) + return str.substr(s); + else + return ""; +} + +template <typename T> +static std::string_view StripTrailingChars(std::string_view str, T chars) +{ + return str.substr(0, str.find_last_not_of(chars) + 1); +} + // Turns "\n\r\t hello " into "hello" (trims at the start and end but not inside). std::string_view StripWhitespace(std::string_view str) { return StripEnclosingChars(str, " \t\r\n"); } +// Turns "\n\r\t hello " into "hello " (trims at the start). +std::string_view StripLeadingWhitespace(std::string_view str) +{ + return StripLeadingChars(str, " \t\r\n"); +} + +// Turns "\n\r\t hello " into "\n\r\t hello" (trims at the end). +std::string_view StripTrailingWhitespace(std::string_view str) +{ + return StripTrailingChars(str, " \t\r\n"); +} + std::string_view StripSpaces(std::string_view str) { return StripEnclosingChars(str, ' '); |
