In This Article

StringTextBufferReader Class

An ITextBufferReader implementation for a string.

public class StringTextBufferReader : ITextBufferReader, ISimpleTextBufferReader
Inheritance:
object object
Implements:
ITextBufferReader ISimpleTextBufferReader

Constructors

StringTextBufferReader(string)

Initializes an instance of the class.

public StringTextBufferReader(string text)
Parameter Type Description
text string

The text to store in the text buffer.

StringTextBufferReader(string, TextPosition, int)

Initializes an instance of the class.

public StringTextBufferReader(string text, TextPosition position, int offset)
Parameter Type Description
text string

The text to store in the text buffer.

position TextPosition

The initial TextPosition of the reader.

offset int

The initial offset of the reader.

Properties

HasStates

Indicates whether there are any saved states on the reader's state stack.

public bool HasStates { get; }

Property Value

bool

IsAtEnd

Indicates whether the current Offset is at the end of the text buffer.

public bool IsAtEnd { get; }

Property Value

bool

IsAtStart

Indicates whether the current Offset is at the start of the text buffer.

public bool IsAtStart { get; }

Property Value

bool

IsWhitespaceOnlyAfterOnLine

Indicates whether only whitespace characters appear at and after the Offset on the current line.

public bool IsWhitespaceOnlyAfterOnLine { get; }

Property Value

bool

IsWhitespaceOnlyBeforeOnLine

Indicates whether only whitespace characters appear before the Offset on the current line.

public bool IsWhitespaceOnlyBeforeOnLine { get; }

Property Value

bool

Length

The number of characters in the text buffer.

public int Length { get; }

Property Value

int

Offset

The current reader offset in the text buffer.

public int Offset { get; set; }

Property Value

int

OffsetDelta

The amount by which to alter the offset values that are parsed.

public int OffsetDelta { get; }

Property Value

int

Position

The current reader TextPosition in the text buffer.

public TextPosition Position { get; }

Property Value

TextPosition

PositionDelta

The amount by which to alter the Position values that are parsed.

public TextPosition PositionDelta { get; }

Property Value

TextPosition

Remarks

The Character portion only affects character offset of the line after the Line count.

Methods

AsTextReader()

Returns a TextReader wrapper for this reader.

public TextReader AsTextReader()

Returns

TextReader

CopyTo(int, Span<char>)

Copies characters from the text buffer into the specified destination span starting at the specified offset.

public void CopyTo(int offset, Span<char> destination)
Parameter Type Description
offset int

The zero-based character offset in the text buffer at which to start copying.

destination Span<char>

The span to which characters should be copied.

GetMemory(int, int)

Returns a ReadOnlyMemory<T> for the specified range of characters in the text buffer.

public ReadOnlyMemory<char> GetMemory(int offset, int length)
Parameter Type Description
offset int

The zero-based character offset in the text buffer at which to start.

length int

The number of characters to include in the memory.

Returns

ReadOnlyMemory<char>:

A ReadOnlyMemory<T> representing the specified range of characters.

GetSubstring(int, int)

Returns a substring from the text buffer.

public string GetSubstring(int offset, int length)
Parameter Type Description
offset int

The offset at which to start the substring.

length int

The number of characters to return.

Returns

string

Peek()

Peeks at the character at the current Offset without advancing.

public char Peek()

Returns

char:

The character at the current offset, or '\0' if at the end of the buffer.

Peek(int)

Peeks at a certain character from the text buffer after the current Offset without seeking past it.

public char Peek(int count)
Parameter Type Description
count int

The number of characters away from the current Offset at which to peek.

Returns

char:

The character that was read.

PeekReverse()

Peeks at the character before the current Offset without moving it.

public char PeekReverse()

Returns

char:

The character before the current offset, or '\0' if at the start of the buffer.

PopState()

Pops the top state from the stack and restores the reader to that state.

public bool PopState()

Returns

bool:

true if a pop occurred; otherwise, false.

PushState()

Pushes the current reader state onto the stack for later restoration.

public void PushState()

Read()

Reads the character at the current Offset and advances the offset by one.

public char Read()

Returns

char:

The character that was read, or '\0' if at the end of the buffer.

ReadReverse()

Reads the character before the current Offset and moves the offset back by one.

public char ReadReverse()

Returns

char:

The character that was read, or '\0' if at the start of the buffer.

ReadReverseThrough(char)

Reverse reads characters from the text buffer until the specified character is read through.

public bool ReadReverseThrough(char ch)
Parameter Type Description
ch char

The desired character.

Returns

bool:

true if the desired character was read; otherwise, false if the start of the text buffer was reached.

ReadReverseThrough(char, int)

Reverse reads characters from the text buffer until the specified character is read through, or the specified offset is reached.

public bool ReadReverseThrough(char ch, int minOffset)
Parameter Type Description
ch char

The desired character.

minOffset int

The minimum offset to check.

Returns

bool:

true if the desired character was read; otherwise, false if the specified offset was reached.

ReadThrough(char)

Reads characters from the text buffer until the specified character is read through.

public bool ReadThrough(char ch)
Parameter Type Description
ch char

The desired character.

Returns

bool:

true if the desired character was read; otherwise, false if the end of the text buffer was reached.

ReadThrough(char, int)

Reads characters from the text buffer until the specified character is read through, or the specified offset is reached.

public bool ReadThrough(char ch, int maxOffset)
Parameter Type Description
ch char

The desired character.

maxOffset int

The maximum offset to check.

Returns

bool:

true if the desired character was read; otherwise, false if the specified offset was reached.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Inherited Members

Extension Methods