/// <summary> /// Advances the reader and reads until a substring specified by <paramref name="indicator" /> is encountered outside quotes. /// The reader's position after executing this method depends on the <paramref name="options" />. /// </summary> /// <param name="indicator">The reader stops when an occurrence of this string instance is encountered.</param> /// <param name="leftQuotes"> /// An array of Unicode characters as the left quotes. /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />. /// The reader will not stop when an <paramref name="indicator" /> is encountered inside a pair of quotes.</param> /// <param name="rightQuotes"> /// An array of Unicode characters as the right quotes. /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />. /// The reader will not stop when an <paramref name="indicator" /> is encountered inside a pair of quotes.</param> /// <param name="options">Specifies the reading options.</param> /// <returns> /// A substring read from the underlying string instance. /// </returns> public string ReadTo(string indicator, char[] leftQuotes, char[] rightQuotes, ReadOptions options = ReadOptions.StopAfterKey | ReadOptions.DiscardKey) { var idx = UnderlyingString.IndexOfWithQuotes(indicator, CurrentPosition, EndPosition - CurrentPosition, leftQuotes, rightQuotes, ComparisonType);; return(_innerReadTo(idx, indicator.Length, options)); }
/// <summary> /// Advances the reader until an occurrence of the specified character is encountered outside quotes. /// </summary> /// <param name="keychar">The reader stops when this character is encountered.</param> /// <param name="leftQuote"> /// The left quote that works together with <paramref name="rightQuote"/> to escape the <paramref name="keychar"/>. /// The reader will not stop when a keychar is encountered inside a pair of quotes. /// </param> /// <param name="rightQuote"> /// The left quote that works together with <paramref name="leftQuote"/> to escape the <paramref name="keychar"/>. /// The reader will not stop when a keychar is encountered inside a pair of quotes. /// </param> /// <param name="skipKeychar"> /// <c>true</c> if the reader stops at the position next to the encountered <paramref name="keychar"/>; /// <c>false</c> if the reader stops at the position of the encountered <paramref name="keychar"/>. /// </param> /// <param name="seekToEndIfKeycharNotFound"> /// <c>true</c> if the reader should advance to the end of the reading scope if <paramref name="keychar"/> is not found. /// <c>false</c> if the reader should stand still if such a character cannot be found. /// </param> /// <returns> /// <c>true</c> if an occurrence <paramref name="keychar" /> is found outside quotes and the reader is advanced to that character; <c>false</c> if no such character is found. /// </returns> public bool SeekTo(char keychar, char leftQuote, char rightQuote, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var keycharPos = UnderlyingString.IndexOfWithQuotes(keychar, CurrentPosition, EndPosition - CurrentPosition, leftQuote, rightQuote); return(_innerSeekTo(keycharPos, 1, skipKeychar, seekToEndIfKeycharNotFound)); }
/// <summary> /// Advances the reader until a character satisfying <paramref name="predicate" /> is encountered outside quotes. /// </summary> /// <param name="predicate">A method to test each character.</param> /// <param name="leftQuotes"> /// The left quotes that work together with <paramref name="rightQuotes"/> to escape the <paramref name="predicate"/>. /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />. /// The reader will not stop when a character satisfying the <paramref name="predicate"/> is encountered inside a pair of quotes. /// </param> /// <param name="rightQuotes"> /// The left quotes that work together with <paramref name="leftQuotes"/> to escape the <paramref name="predicate"/>. /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />. /// The reader will not stop when a character satisfying the <paramref name="predicate"/> is encountered inside a pair of quotes. /// </param> /// <param name="skipKeychar"><c>true</c> if the reader stops at the position next to the first encountered character satisfying the <paramref name="predicate" />; /// <c>false</c> if the reader stops at the position of such a character.</param> /// <param name="seekToEndIfKeycharNotFound"><c>true</c> if the reader should advance to the end of the reading scope if no character satisfying the <paramref name="predicate" /> is found; /// <c>false</c> if the reader should stand still if such a character cannot be found.</param> /// <returns> /// <c>true</c> if the reader is advanced to a character outside quotes satisfying the specified <paramref name="predicate" />; <c>false</c> if no such character is found. /// </returns> public bool SeekTo(Func <char, bool> predicate, char[] leftQuotes, char[] rightQuotes, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var keycharPos = UnderlyingString.IndexOfWithQuotes(predicate, CurrentPosition, EndPosition - CurrentPosition, leftQuotes, rightQuotes); return(_innerSeekTo(keycharPos, 1, skipKeychar, seekToEndIfKeycharNotFound)); }
/// <summary> /// Advances the reader until an occurrence of the specified string is encountered outside quotes. /// </summary> /// <param name="keyword">The reader stops when this string is encountered.</param> /// <param name="leftQuotes"> /// The left quotes that work together with <paramref name="rightQuotes"/> to escape the <paramref name="predicate"/>. /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />. /// The reader will not stop when a character satisfying the <paramref name="predicate"/> is encountered inside a pair of quotes. /// </param> /// <param name="rightQuotes"> /// The left quotes that work together with <paramref name="leftQuotes"/> to escape the <paramref name="predicate"/>. /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />. /// The reader will not stop when a character satisfying the <paramref name="predicate"/> is encountered inside a pair of quotes. /// </param> /// <param name="skipKeyword"> /// <c>true</c> if the reader stops at the position next to the last character of the encountered keyword. /// <c>false</c> if the reader stops at the position of the first character of the encountered keyword. /// </param> /// <param name="seekToEndIfKeywordNotFound"> /// <c>true</c> if the reader should advance to the end of the reading scope if <paramref name="keyword"/> is not found. /// <c>false</c> if the reader should stand still if such a keyword cannot be found. /// </param> /// <returns> /// <c>true</c> if an occurrence of <paramref name="keyword" /> is encountered outside quotes and the reader is advanced to that keyword; <c>false</c> if no such keyword is found. /// </returns> public bool SeekTo(string keyword, char[] leftQuotes, char[] rightQuotes, bool skipKeyword = true, bool seekToEndIfKeywordNotFound = true) { var keywordPos = UnderlyingString.IndexOfWithQuotes(keyword, CurrentPosition, EndPosition - CurrentPosition, leftQuotes, rightQuotes, ComparisonType); return(_innerSeekTo(keywordPos, keyword.Length, skipKeyword, seekToEndIfKeywordNotFound)); }