StringView class

A wrapper class for Strings which adds a cursor tracking an offset in the string.

A StringView allows a String to be consumed from start to end, as well as providing operations that are especially useful for argument parsing.

Constructors

StringView(String buffer, {bool isRestBlock = false})
Create a new StringView wrapping buffer.

Properties

buffer String
The string wrapped by this StringView.
final
current String
The character at the current cursor position.
no setter
end int
The largest possible index for the cursor.
no setter
eof bool
Whether the entire buffer has been consumed.
no setter
hashCode int
The hash code for this object.
no setterinherited
history List<int>
A record of all the previous indices the cursor was at preceding an operation.
getter/setter pair
index int
The current index of the cursor in buffer.
getter/setter pair
isRestBlock bool
Whether remaining should be considered to be one "block" of text, which getQuotedWord will return all of.
getter/setter pair
isWhitespace bool
Whether the current character is whitespace.
no setter
remaining String
The part of buffer that has yet to be consumed, spanning from index to the end of buffer.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copy() StringView
Create a copy of this StringView, with an identical buffer and index.
escape(int start, int end) String
Escape and return a portion of buffer.
getQuotedWord() String
Consume and return the next word or quoted portion in buffer.
getWord() String
Consume and return the next word in buffer, disregarding quotes.
isEscaped(int index) bool
Return whether the character at index is escaped.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
skipPattern(Pattern p) Match?
Match p at the text directly after the cursor and skip over the match if it exists, else return null.
skipString(String s) bool
Skip over s and return true if s matches the text after the cursor, and return false otherwise.
skipWhitespace() → void
Skip to the next non-whitespace character in buffer.
toString() String
A string representation of this object.
override
undo() → void
Revert the previous operation if there is one.

Operators

operator ==(Object other) bool
The equality operator.
inherited