diff options
Diffstat (limited to 'source/core/slang-string.cpp')
| -rw-r--r-- | source/core/slang-string.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index 54703def1..8b2a35b3f 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -7,9 +7,15 @@ namespace Slang SLANG_RETURN_NEVER void signalUnexpectedError(char const* message) { + // Can be useful to uncomment during debug when problem is on CI + // printf("Unexpected: %s\n", message); throw InternalError(message); } + SLANG_FORCE_INLINE static bool _isWhiteSpace(char c) + { + return c == ' ' || c == '\t'; + } // OSString @@ -100,6 +106,17 @@ namespace Slang return endsWith(UnownedTerminatedStringSlice(str)); } + + UnownedStringSlice UnownedStringSlice::trim() const + { + const char* start = m_begin; + const char* end = m_end; + + while (start < end && _isWhiteSpace(*start)) start++; + while (end > start && _isWhiteSpace(end[-1])) end--; + return UnownedStringSlice(start, end); + } + // StringSlice |
