/// <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 and reads until a substring specified by <paramref name="indicator" /> is encountered. /// 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="options">Specifies the reading options.</param> /// <returns> /// A substring read from the underlying string instance. /// </returns> public string ReadTo(string indicator, ReadOptions options = ReadOptions.StopAfterKey | ReadOptions.DiscardKey) { var idx = options.HasFlag(ReadOptions.InLine) ? UnderlyingString.InlineIndexOf(indicator, CurrentPosition, EndPosition - CurrentPosition, ComparisonType) : UnderlyingString.IndexOf(indicator, CurrentPosition, EndPosition - CurrentPosition, ComparisonType); return(_innerReadTo(idx, indicator.Length, options)); }
string _trim(int startIndex, int endIndex, bool trimStart, bool trimEnd) { if (startIndex == endIndex) { return(string.Empty); } if (trimStart) { while (UnderlyingString[startIndex].IsWhiteSpace()) { ++startIndex; if (startIndex >= endIndex) { return(string.Empty); } } } if (trimEnd) { while (UnderlyingString[endIndex - 1].IsWhiteSpace()) { --endIndex; if (endIndex <= startIndex) { return(string.Empty); } } } return(UnderlyingString.Substring(startIndex, endIndex - startIndex)); }
private StoragePath?GetParent() { if (IsRootPathOnly()) { return(null); } // Find the index of the first separator from behind and then (to fulfill spec) continue // walking down until the last consecutive char has been passed. var rootLength = GetRootLength(); var endIndex = Length; while (endIndex > rootLength && !IsDirectorySeparator(UnderlyingString[endIndex - 1])) { endIndex--; } while (endIndex > rootLength && IsDirectorySeparator(UnderlyingString[endIndex - 1])) { endIndex--; } // If there has been no directory separator there is no parent (can happen with relative paths). if (endIndex <= 0) { return(null); } return(FileSystem.GetPath(UnderlyingString.Substring(0, endIndex))); }
/// <summary> /// Advances the reader until an occurrence of any of the specified characters is encountered. /// </summary> /// <param name="keychars">The reader stops when any of these characters is encountered.</param> /// <param name="skipKeychar"> /// <c>true</c> if the reader stops at the position next to the encountered keychar. /// <c>false</c> if the reader stops at the position of the encountered keychar. /// </param> /// <param name="seekToEndIfKeycharNotFound"> /// <c>true</c> if the reader should advance to the end of the reading scope if none of <paramref name="keychars"/> is 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 of any of the <paramref name="keywords" /> is found and the reader is advanced to that character; /// <c>false</c> if no such character is found. /// </returns> public int SeekTo(char[] keychars, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var keycharPos = UnderlyingString.IndexOfAny(keychars, CurrentPosition, EndPosition - CurrentPosition, out var keycharIndex); _innerSeekTo(keycharPos, 1, skipKeychar, seekToEndIfKeycharNotFound); return(keycharIndex); }
/// <summary> /// Reads a string consisting of ASCII letters and digits, plus characters specified in <paramref name="additionalChars"/> at the beginning of the reading scope. /// </summary> /// <param name="additionalChars">Specifies additional characters to read.</param> /// <returns>A string at the beginning of the current reading scope, consisting of ASCII letters and digits plus <paramref name="additionalChars"/>.</returns> public string ReadASCIILettersAndDigits(params char[] additionalChars) { var pos = CurrentPosition; while (!EOF && (First.IsASCIILetterOrDigit() || First.In(additionalChars))) { Advance(); } return(UnderlyingString.Substring(pos, CurrentPosition - pos)); }
/// <summary> /// Advances this reader to the end of the search scope and returns a substring starting from the current position to the end of the search scope. NOTE that after executing this method, this reader is marked <see cref="EOF"/> and is no longer readable. /// </summary> /// <returns>A substring of the underlying string of this reader, starting from the current position to the end of the reading scope, if the current reader is not marked EOF; otherwise, <see cref="String.Empty"/>.</returns> public string ReadToEnd() { if (CurrentPosition == EndPosition) { return(string.Empty); } else { var output = UnderlyingString.Substring(CurrentPosition, EndPosition - CurrentPosition); CurrentPosition = EndPosition; return(output); } }
/// <summary> /// Advances the reader until an occurrence of any of the specified <paramref name="keywords"/> is encountered outside quotes. /// </summary> /// <param name="keywords">The reader stops when any of these strings is encountered.</param> /// <param name="primaryLeftQuotes">Specifies an array of Unicode characters as the primary 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="primaryRightQuotes" />.</param> /// <param name="primaryRightQuotes">Specifies an array of Unicode characters as the primary 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="primaryLeftQuotes" />.</param> /// <param name="secondaryLeftQuotes">Specifies an array of Unicode characters as the secondary 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="secondaryRightQuotes" />. Secondary quotes are escaped when they are inside a pair of primary quotes.</param> /// <param name="secondaryRightQuotes">Specifies an array of Unicode characters as the secondary 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="secondaryLeftQuotes" />. Secondary quotes are escaped when they are inside a pair of primary 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 none of <paramref name="keywords"/> is found. /// <c>false</c> if the reader should stand still if such a keyword cannot be found. /// </param> /// <returns> /// THe index of the encountered keyword in the <paramref name="keywords" />, if any ouccrrance of the <paramref name="keywords"/> is encountered outside quotes and the reader has advanced to that keyword; /// -1 if no keyword is encountered. /// </returns> public int SeekTo(string[] keywords, char[] primaryLeftQuotes, char[] primaryRightQuotes, char[] secondaryLeftQuotes, char[] secondaryRightQuotes, bool skipKeyword = true, bool seekToEndIfKeywordNotFound = true) { var keywordSearchResult = UnderlyingString.IndexOfAnyWithQuotes(keywords, CurrentPosition, EndPosition - CurrentPosition, primaryLeftQuotes, primaryRightQuotes, secondaryLeftQuotes, secondaryRightQuotes, ComparisonType); if (keywordSearchResult == null) { _innerSeekTo(-1, 0, skipKeyword, seekToEndIfKeywordNotFound); return(-1); } else { _innerSeekTo(keywordSearchResult.Position, keywordSearchResult.Value.Length, skipKeyword, seekToEndIfKeywordNotFound); return(keywordSearchResult.HitIndex); } }
/// <summary> /// Advances the reader until an occurrence of any of the specified strings is encountered. /// </summary> /// <param name="keywords">The reader stops when any of these strings is encountered.</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 none of <paramref name="keywords"/> is 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 any of the <paramref name="keywords" /> is found and the reader is advanced to that keyword; /// <c>false</c> if no such keyword is found. /// </returns> public int SeekTo(string[] keywords, bool skipKeyword = true, bool seekToEndIfKeywordNotFound = true) { var keywordSearchResult = UnderlyingString.IndexOfAny(keywords, CurrentPosition, EndPosition - CurrentPosition); if (keywordSearchResult == null) { _innerSeekTo(-1, 0, skipKeyword, seekToEndIfKeywordNotFound); return(-1); } else { _innerSeekTo(keywordSearchResult.Position, keywordSearchResult.Value.Length, skipKeyword, seekToEndIfKeywordNotFound); return(keywordSearchResult.HitIndex); } }
/// <summary> /// Advances the reader until an occurrence of any of the specified characters is encountered outside quotes. /// </summary> /// <param name="keychars">The reader stops when any of these characters 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="skipKeychar"> /// <c>true</c> if the reader stops at the position next to the encountered keychar. /// <c>false</c> if the reader stops at the position of the encountered keychar. /// </param> /// <param name="seekToEndIfKeycharNotFound"> /// <c>true</c> if the reader should advance to the end of the reading scope if none of <paramref name="keychars"/> is found. /// <c>false</c> if the reader should stand still if such a character cannot be found. /// </param> /// <returns> /// '\0' if none of <paramref name="keychars"/> is found; ohterwise, the encountered keychar. /// </returns> public char SeekTo(char[] keychars, char[] leftQuotes, char[] rightQuotes, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var keycharPos = UnderlyingString.IndexOfAnyWithQuotes(keychars, CurrentPosition, EndPosition - CurrentPosition, leftQuotes, rightQuotes); if (keycharPos == -1) { _innerSeekTo(-1, 0, skipKeychar, seekToEndIfKeycharNotFound); return('\0'); } else { _innerSeekTo(keycharPos, 1, skipKeychar, seekToEndIfKeycharNotFound); return(UnderlyingString[keycharPos]); } }
StringReader _innerReadToMatchAsReader(char leftChar, char rightChar, char[] leftQuotes, char[] rightQuotes, ReadOptions mode) { var idx = UnderlyingString.IndexOfNextMatch(leftChar, rightChar, leftQuotes, rightQuotes, CurrentPosition); if (idx == -1) { return(null); } else { if (UnderlyingString[CurrentPosition] == leftChar && mode.HasFlag(ReadOptions.DiscardKey)) { ++CurrentPosition; } return(_innerReadToAsReader(idx, 1, mode)); } }
/// <summary> /// For internal use only. The same as <see cref="SubstringBeforeCurrentPosition"/> except that the white spaces at the end of returned string are trimmed. /// </summary> /// <param name="prevPos">Provides a position prior to the reader's <see cref="CurrentPosition"/>.</param> /// <returns>A substring starting from the specified <paramref name="prevPos" /> to the character previous to the <see cref="CurrentPosition" />. Note the first character of the current reading scope is not contained in the returned substring. <c>null</c> is returned if <paramref name="prevPos" /> equals <see cref="CurrentPosition" />.</returns> internal string InnerSubstringBeforeCurrentPositionWithTrimEnd(int prevPos) { if (prevPos == CurrentPosition) { return(null); } var pos = CurrentPosition - 1; while (UnderlyingString[pos].IsWhiteSpace()) { --pos; if (pos < prevPos) { return(null); } } return(UnderlyingString.Substring(prevPos, pos + 1 - prevPos)); }
/// <summary> /// Reads a variable name from this reader. The valid first character of the variable name is defined by the <paramref name="isValidVariableFirstChr"/>, and a valid variable name character (except the first character) is defined by <paramref name="isValidVariableChr"/>. /// </summary> /// <returns>A variable name read from this reader.</returns> public string ReadVariableName(Func <char, bool> isValidVariableFirstChr, Func <char, bool> isValidVariableChr) { var pos = CurrentPosition; //! DO NOT use MarkPosition; it is for external use. if (isValidVariableFirstChr(First)) { Advance(); } else { return(null); } while (!EOF && isValidVariableChr(First)) { Advance(); } return(UnderlyingString.Substring(pos, CurrentPosition - pos)); }
/// <summary> /// Reads a WAS reference name from this reader. The valid first character of the variable name can either be a ASCII letter, or '_'; and a valid variable name character (except the first character) can either be a ASCII letter or ASCII digit or '_' or '-'. /// </summary> /// <returns>A variable name read from this reader.</returns> public string ReadWASReferenceName() { var pos = CurrentPosition; //! DO NOT use MarkPosition; it is for external use. if (First.IsASCIILetter() || First == '_') { Advance(); } else { return(null); } while (!EOF && First.IsASCIILetterOrDigit() || First == '_' || First == '-') { Advance(); } return(UnderlyingString.Substring(pos, CurrentPosition - pos)); }
private StoragePath TrimEndingDirectorySeparatorImpl() { if (!EndsWithDirectorySeparator) { return(this); } if (Length == 1) { throw new InvalidOperationException(ExceptionStrings.StoragePath.TrimmingResultsInEmptyPath()); } var trimmedPath = UnderlyingString.Substring(0, UnderlyingString.Length - 1); try { return(FileSystem.GetPath(trimmedPath)); } catch (Exception ex) { throw new InvalidOperationException(ExceptionStrings.StoragePath.TrimmingResultsInInvalidPath(), ex); } }
private string GetName() { if (IsRootPathOnly()) { return(string.Empty); } // Specification requires us to ignore exactly one trailing directory separator character. // The name starts at the position of the last directory separator character except for // that trailing one. var startIndex = 0; var endIndex = EndsWithDirectorySeparator ? Length - 2 : Length - 1; for (var i = endIndex; i >= 0; i--) { if (IsDirectorySeparator(UnderlyingString[i])) { startIndex = i + 1; break; } } return(UnderlyingString.Substring(startIndex, endIndex - startIndex + 1)); }
/// <summary> /// Advances the reader to the beginning of the next line. If the current line is the last line, the reader advances to the end of the underlying string. /// </summary> /// <param name="skipBlankLines"><c>true</c> to indicate the reader should skip all blank lines it encounters before a non-empty line is reached. /// If no non-empty line is found, the reader will advance to the end of the underlying string. /// </param> public void SeekToNextLine(bool skipBlankLines = true) { var newline = Environment.NewLine; var idx = UnderlyingString.IndexOf(newline, CurrentPosition, EndPosition - CurrentPosition, ComparisonType); if (idx == -1) { CurrentPosition = EndPosition; } else { CurrentPosition = idx + newline.Length; } while (UnderlyingString.StartsWith(CurrentPosition, newline)) { CurrentPosition += newline.Length; if (CurrentPosition > EndPosition) { CurrentPosition = EndPosition; break; } } }
/// <summary> /// For internal use only. The internal version of <see cref="SubstringBeforeCurrentPosition"/> without argument check. /// </summary> /// <param name="prevPos">Provides a position prior to the reader's <see cref="CurrentPosition"/>.</param> /// <returns>A substring starting from the specified <paramref name="prevPos" /> to the character previous to the <see cref="CurrentPosition" />. Note the first character of the current reading scope is not contained in the returned substring. <c>null</c> is returned if <paramref name="prevPos" /> equals <see cref="CurrentPosition" />.</returns> internal string InnerSubstringBeforeCurrentPosition(int prevPos) { return(CurrentPosition == prevPos ? null : UnderlyingString.Substring(prevPos, CurrentPosition - prevPos)); }
/// <summary> /// Advances the reader and reads until any substring specified in <paramref name="indicators" /> is encountered outside quotes. /// The reader's position after executing this method depends on the <paramref name="options" />. /// </summary> /// <param name="indicators">The reader stops an occurrence of this string instances is encountered.</param> /// <param name="leftQuote">The left quote. The reader will not stop when an <paramref name="indicator" /> is encountered inside a pair of quotes.</param> /// <param name="rightQuote">The right quote. 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[] indicators, char leftQuote, char rightQuote, ReadOptions options = ReadOptions.StopAfterKey | ReadOptions.DiscardKey) { var idx = UnderlyingString.IndexOfAnyWithQuotes(indicators, CurrentPosition, EndPosition - CurrentPosition, leftQuote, rightQuote, ComparisonType);; return(_innerReadTo(idx.Position, idx.Value.Length, options)); }
public int GetReadingScopeHashCode() { return(UnderlyingString.GetHashCode(CurrentPosition, ReadingScopeLength)); }
public bool StartsWith(string str) => (str.Length <= Length) && UnderlyingString.IndexOf(str, Index, str.Length) == Index;
/// <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 a character satisfying <paramref name="predicate"/> is encountered. /// </summary> /// <param name="predicate">A method to test each character.</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 has advanced to a character satisfying the specified <paramref name="predicate"/>; <c>false</c> if no such character is found.</returns> public void SeekTo(Func <char, bool> predicate, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var idx = UnderlyingString.IndexOf(predicate, CurrentPosition); _innerSeekTo(idx, 1, skipKeychar, seekToEndIfKeycharNotFound); }
//TODO this file is not complete #region SeekTo A Keyword /// <summary> /// Advances the reader until an occurrence of the specified string is encountered. /// </summary> /// <param name="keyword">The reader stops when this string is encountered.</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 and the reader is advanced to that keyword; <c>false</c> if no such keyword is found. /// </returns> public bool SeekTo(string keyword, bool skipKeyword = true, bool seekToEndIfKeywordNotFound = true) { var keywordPos = UnderlyingString.IndexOf(keyword, CurrentPosition, EndPosition - CurrentPosition); return(_innerSeekTo(keywordPos, keyword.Length, skipKeyword, seekToEndIfKeywordNotFound)); }
/// <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 an occurrence of the specified character is encountered. /// </summary> /// <param name="keychar">The reader stops when this character is encountered.</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 and the reader has advanced to that character; <c>false</c> if no such character is found. /// </returns> public bool SeekTo(char keychar, bool skipKeychar = true, bool seekToEndIfKeycharNotFound = true) { var keycharPos = UnderlyingString.IndexOf(keychar, CurrentPosition, EndPosition - CurrentPosition); return(_innerSeekTo(keycharPos, 1, skipKeychar, seekToEndIfKeycharNotFound)); }
public override string ToString() { return(UnderlyingString.Substring(Index, Length)); }
/// <summary> /// Returns a substring of the underlying string instance of this reader, starting from the current position to the limit of this reader. /// </summary> /// <returns> /// A <see cref="System.String" /> that is a substring of the underlying string instance of this reader. /// </returns> public override string ToString() { return(UnderlyingString.Substring(CurrentPosition, EndPosition - CurrentPosition)); }
public override string ToString() { return(UnderlyingString?.Substring(Index, Length) ?? String.Empty); }
/// <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)); }