StringTextStream

class StringTextStream(source: String)

A stream of text characters that can be processed sequentially. This stream maintains a current position (i.e., offset in the string) from which all reading operations begin. The stream is advanced by read operations. The stream is not advanced by peek operations.

Parameters

source

The source text for this stream.

Constructors

Link copied to clipboard
constructor(source: String)

Functions

Link copied to clipboard
fun advance(length: Int, errCondition: String)

Advance the position by the given length. Throws an exception if this would advance beyond the end of the stream.

Link copied to clipboard

Advances the position if the given text is next in the stream. Otherwise, the offset is not updated.

Link copied to clipboard

Advances the position until a whitespace character is found (i.e., one of ' ', '\r', '\n', '\t').

Link copied to clipboard

Advances the position until a non-whitespace character is found (i.e., not one of ' ', '\r', '\n', '\t').

Link copied to clipboard

Determines if the next several characters in the stream match the given text without advancing the position.

Link copied to clipboard
fun readOrThrow(errCondition: String): Char

Returns the next character in the stream and advances the position. Throws an exception if the end of the stream would be exceeded.

Link copied to clipboard
fun readThrough(text: String, errCondition: String): String

Returns contents of the stream up to and including the given text and advances the position. Throws an exception if the text is not encountered before the end of the stream.

Link copied to clipboard
fun readUntil(text: String, errCondition: String): String

Returns contents of the stream up to but not including the given text and advances the position. Throws an exception if the text is not encountered before the end of the stream.

Link copied to clipboard

Returns an XML name from the stream and advances the position. Throws an exception if unable to find a valid XML name start character. See https://www.w3.org/TR/xml/#NT-Name for name character rules.

Link copied to clipboard
fun rewind(length: Int, errCondition: String)

Moves the stream position back by length characters. Throws an exception if this would exceed the bounds of the stream.