In This Article

StringTextBufferReader Class

Represents an ITextBufferReader implementation for a string.

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

Constructors

StringTextBufferReader(string)

Initializes a new instance of the StringTextBufferReader class.

public StringTextBufferReader(string text)
Parameter Type Description
text string

The text to store in the text buffer.

StringTextBufferReader(string, TextPosition, int)

Initializes a new instance of the StringTextBufferReader 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

HasStackEntries

Gets whether there are entries on the stack.

public bool HasStackEntries { get; }

Property Value

bool:

true if there are entries on the stack; otherwise, false.

IsAtEnd

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

public bool IsAtEnd { get; }

Property Value

bool:

true if the current Offset is at the end of the text buffer; otherwise, false.

IsAtStart

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

public bool IsAtStart { get; }

Property Value

bool:

true if the current Offset is at the start of the text buffer; otherwise, false.

IsWhitespaceOnlyAfterOnLine

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

public bool IsWhitespaceOnlyAfterOnLine { get; }

Property Value

bool:

true if only whitespace characters appear at and after the Offset on the current line; otherwise, false.

IsWhitespaceOnlyBeforeOnLine

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

public bool IsWhitespaceOnlyBeforeOnLine { get; }

Property Value

bool:

true if only whitespace characters appear before the Offset on the current line; otherwise, false.

Length

Gets the number of characters in the text buffer.

public int Length { get; }

Property Value

int:

The number of characters in the text buffer.

Offset

Gets or sets the current reader offset in the text buffer.

public int Offset { get; set; }

Property Value

int:

The current reader offset in the text buffer.

Remarks

For performance reasons there is no bounds check on the setter.

OffsetDelta

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

public int OffsetDelta { get; }

Property Value

int:

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

Position

Gets the current reader TextPosition in the text buffer.

public TextPosition Position { get; }

Property Value

TextPosition:

The current reader TextPosition in the text buffer.

PositionDelta

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

public TextPosition PositionDelta { get; }

Property Value

TextPosition:

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

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:

A TextReader wrapper for this reader.

GetSubstring(int, int)

Returns a substring from the text buffer using Newline for line ends.

public string GetSubstring(int startOffset, int substringLength)
Parameter Type Description
startOffset int

The offset at which to retrieve the text.

substringLength int

The number of characters to return.

Returns

string:

The substring from the text buffer using Newline for line ends.

Peek()

Peeks at a single character from the text buffer without seeking past it.

public char Peek()

Returns

char:

The character that was read.

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()

Reverse peeks at a single character from the text buffer without seeking past it.

public char PeekReverse()

Returns

char:

The character that was read.

Pop()

Pops the top offset from the stack and moves the Offset to that offset.

public bool Pop()

Returns

bool:

true if a pop occurred; otherwise, false.

PopAll()

Pops the all offsets from the stack and moves the Offset to the offset that was on the bottom of the stack.

public bool PopAll()

Returns

bool:

true if a pop occurred; otherwise, false.

Push()

Pushes the Offset onto the stack for later restoration.

public void Push()

Read()

Reads a single character from the text buffer and seeks forward one offset.

public char Read()

Returns

char:

The character that was read.

ReadReverse()

Reverse reads a single character from the text buffer and seeks backward one offset.

public char ReadReverse()

Returns

char:

The character that was read.

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()

Creates and returns a string representation of the current object.

public override string ToString()

Returns

string:

A string representation of the current object.

Inherited Members