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.
IsAtEnd
Indicates whether the current Offset is at the end of the text buffer.
IsAtStart
Indicates whether the current Offset is at the start of the text buffer.
IsWhitespaceOnlyAfterOnLine
Indicates whether only whitespace characters appear at and after the Offset on the current line.
IsWhitespaceOnlyBeforeOnLine
Indicates whether only whitespace characters appear before the Offset on the current line.
Length
The number of characters in the text buffer.
Offset
The current reader offset in the text buffer.
OffsetDelta
The amount by which to alter the offset values that are parsed.
Position
The current reader TextPosition in the text buffer.
PositionDelta
The amount by which to alter the Position values that are parsed.
public TextPosition PositionDelta { get; }
Property Value
Remarks
The Character portion only affects character offset of the line after the Line count.
Methods
AsTextReader()
Returns a TextReader wrapper for this reader.
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
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.
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.
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:
trueif the desired character was read; otherwise,falseif 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:
trueif the desired character was read; otherwise,falseif 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:
trueif the desired character was read; otherwise,falseif 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:
trueif the desired character was read; otherwise,falseif the specified offset was reached.
ToString()
Returns the string representation of this object.
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()