From 97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 4 Oct 2021 14:15:51 -0400 Subject: Removing exceptions from core/compiler-core (#1953) * #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Stream. Working on all tests. * Split out CharEncode. * Make method names lower camel. m_prefix in Writer/Reader * Tidy up around CharEncode interface. * Small improvements around encode/decode. * Better use of types. * Remove readLine from TextReader. * Remove exceptions from Stream/Text handling. * Fix some typos. * Fix tabbing. * Fix missing override. * Remove remaining exception throw/catch via using signal mechanism. * Remove exceptions that are not used anymore. * Document the Stream interface. * Remove index for decoding 'get byte' function. * Fix CharReader -> ByteReader. --- source/core/slang-string.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source/core/slang-string.h') diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 6b9a73bcb..85f7b894f 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -168,6 +168,9 @@ namespace Slang /// Trims any 'c' from the start or the end, and returns as a substring UnownedStringSlice trim(char c) const; + /// Trims any horizonatl whitespace from start and returns as a substring + UnownedStringSlice trimStart() const; + HashCode getHashCode() const { return Slang::getHashCode(m_begin, size_t(m_end - m_begin)); @@ -409,7 +412,7 @@ namespace Slang static String fromWString(const wchar_t * wstr); static String fromWString(const wchar_t * wstr, const wchar_t * wend); static String fromWChar(const wchar_t ch); - static String fromUnicodePoint(unsigned int codePoint); + static String fromUnicodePoint(Char32 codePoint); String() { } @@ -619,9 +622,9 @@ namespace Slang len = getLength() - id; #if _DEBUG if (id < 0 || id >= getLength() || (id + len) > getLength()) - throw "SubString: index out of range."; + SLANG_ASSERT_FAILURE("SubString: index out of range."); if (len < 0) - throw "SubString: length less than zero."; + SLANG_ASSERT_FAILURE("SubString: length less than zero."); #endif return StringSlice(m_buffer, id, id + len); } @@ -997,9 +1000,9 @@ namespace Slang { #if _DEBUG if (id >= length || id < 0) - throw "Remove: Index out of range."; + SLANG_ASSERT_FAILURE("Remove: Index out of range."); if (len < 0) - throw "Remove: remove length smaller than zero."; + SLANG_ASSERT_FAILURE("Remove: remove length smaller than zero."); #endif int actualDelLength = ((id + len) >= length) ? (length - id) : len; for (int i = id + actualDelLength; i <= length; i++) -- cgit v1.2.3