From 3f5460a5ff318751b3effb85c4c57bbdd46e9ece Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Thu, 7 May 2026 09:24:55 +0200 Subject: Core: Implement automatic symbol demangling --- Source/Core/Common/StringUtil.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common/StringUtil.cpp') 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 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 +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 +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, ' '); -- cgit v1.2.3