summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string-util.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-06-19 16:05:40 -0400
committerGitHub <noreply@github.com>2019-06-19 16:05:40 -0400
commit442f8c6d3d42b892e3f13128bcb6487ff7508f0d (patch)
tree79746a98390c49bba9639ee84999304731210a8b /source/core/slang-string-util.h
parent48ae5496516878768d7de241b9b7fbba91fbaa74 (diff)
Make extractLine return a bool. (#991)
Diffstat (limited to 'source/core/slang-string-util.h')
-rw-r--r--source/core/slang-string-util.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/core/slang-string-util.h b/source/core/slang-string-util.h
index b9618c17f..74ec75dc6 100644
--- a/source/core/slang-string-util.h
+++ b/source/core/slang-string-util.h
@@ -78,15 +78,16 @@ struct StringUtil
/// Create a blob from a string
static ComPtr<ISlangBlob> createStringBlob(const String& string);
- /// Returns a line extracted from the start of ioText.
+ /// Extracts a line and stores the remaining text in ioText, and the line in outLine. Returns true if has a line.
///
- /// At the end of all the text a 'special' null UnownedStringSlice with a null 'begin' pointer is returned.
- /// The slice passed in will be modified on output to contain the remaining text, starting at the beginning of the next line.
- /// As en empty final line is still a line, the special null UnownedStringSlice is the last value ioText after the last valid line is returned.
+ /// As well as indicating end of text with the return value, at the end of all the text a 'special' null UnownedStringSlice with a null 'begin'
+ /// pointer is also returned as the outLine.
+ /// ioText will be modified to contain the remaining text, starting at the beginning of the next line.
+ /// As an empty final line is still a line, the special null UnownedStringSlice is the last value ioText after the last valid line is returned.
///
/// NOTE! That behavior is as if line terminators (like \n) act as separators. Thus input of "\n" will return *two* lines - an empty line
/// before and then after the \n.
- static UnownedStringSlice extractLine(UnownedStringSlice& ioText);
+ static bool extractLine(UnownedStringSlice& ioText, UnownedStringSlice& outLine);
/// Given text, splits into lines stored in outLines. NOTE! That lines is only valid as long as textIn remains valid
static void calcLines(const UnownedStringSlice& textIn, List<UnownedStringSlice>& lines);
@@ -105,7 +106,7 @@ public:
const UnownedStringSlice* operator->() const { return &m_line; }
Iterator& operator++()
{
- m_line = StringUtil::extractLine(m_remaining);
+ StringUtil::extractLine(m_remaining, m_line);
return *this;
}
Iterator operator++(int) { Iterator rs = *this; operator++(); return rs; }
@@ -122,7 +123,7 @@ public:
UnownedStringSlice m_remaining;
};
- Iterator begin() const { UnownedStringSlice remaining(m_text); UnownedStringSlice line = StringUtil::extractLine(remaining); return Iterator(line, remaining); }
+ Iterator begin() const { UnownedStringSlice remaining(m_text), line; StringUtil::extractLine(remaining, line); return Iterator(line, remaining); }
Iterator end() const { UnownedStringSlice term(nullptr, nullptr); return Iterator(term, term); }
/// Ctor