Farkle


CharStream Type

A data structure that supports efficient access to a read-only sequence of characters. It is not thread-safe.

Constructors

Constructor Description

CharStream(reader, ?leaveOpen, ?bufferSize)

Full Usage: CharStream(reader, ?leaveOpen, ?bufferSize)

Parameters:
    reader : TextReader - The text reader to read characters from.
    ?leaveOpen : bool - Whether to keep the underlying text reader open when the character stream gets disposed.
    ?bufferSize : int - The size of the stream's internal character buffer. It has a default value.

Returns: CharStream

Creates a CharStream that lazily reads its characters from a TextReader.

reader : TextReader

The text reader to read characters from.

?leaveOpen : bool

Whether to keep the underlying text reader open when the character stream gets disposed.

?bufferSize : int

The size of the stream's internal character buffer. It has a default value.

Returns: CharStream
ArgumentOutOfRangeException bufferSize is negative or zero

CharStream(str)

Full Usage: CharStream(str)

Parameters:
    str : string

Returns: CharStream

Creates a CharStream from a string.

str : string
Returns: CharStream

CharStream(mem)

Full Usage: CharStream(mem)

Parameters:
Returns: CharStream

Creates a CharStream from a ReadOnlyMemory{Char}.

mem : ReadOnlyMemory<char>
Returns: CharStream

Instance members

Instance member Description

this.AdvanceBy

Full Usage: this.AdvanceBy

Parameters:
    count : int

Advances the stream's current position by count characters. This function invalidates the indices for the stream's CharacterBuffer and the characters that were advanced might later be released from memory.

Both Windows line ending chatacters must be advanced at the same time, otherwise the stream's current position will be incorrect.

count : int
ArgumentOutOfRangeException count is negative.

this.CharacterBuffer

Full Usage: this.CharacterBuffer

Returns: ReadOnlySpan<char>

A read-only span of characters that contains all available characters at and after the stream's current position.

Returns: ReadOnlySpan<char>

this.CurrentPosition

Full Usage: this.CurrentPosition

Returns: inref<Position>

The position of the next character the stream has to read.

Returns: inref<Position>

this.GetPositionAtOffset

Full Usage: this.GetPositionAtOffset

Parameters:
    ofs : int

Returns: Position

Returns the position of the character at ofs characters after the current position.

ofs : int
Returns: Position
ArgumentOutOfRangeException ofs is negative.

this.ObjectStore

Full Usage: this.ObjectStore

Returns: IDictionary<string, obj>
Returns: IDictionary<string, obj>

this.TryExpandPastOffset

Full Usage: this.TryExpandPastOffset

Parameters:
    ofs : int

Returns: bool

Tries to load the ofsth character after the stream's current position. If it does not exist, returns false. This function invalidates the stream's CharacterBuffer but keeps the indices of the new buffer valid.

ofs : int
Returns: bool
ArgumentOutOfRangeException ofs is negative.