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, Int32)
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 | Int32 | The initial offset of the reader. |
Properties
HasStackEntries
Gets whether there are entries on the stack.
public bool HasStackEntries { get; }
Property Value
- Boolean:
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
IsAtStart
Gets whether the current Offset is at the start of the text buffer.
public bool IsAtStart { get; }
Property Value
IsWhitespaceOnlyAfterOnLine
Gets whether only whitespace characters appear at and after the Offset on the current line.
public bool IsWhitespaceOnlyAfterOnLine { get; }
Property Value
IsWhitespaceOnlyBeforeOnLine
Gets whether only whitespace characters appear before the Offset on the current line.
public bool IsWhitespaceOnlyBeforeOnLine { get; }
Property Value
Length
Gets 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
- Int32:
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
- Int32:
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.
GetSubstring(Int32, Int32)
Returns a substring from the text buffer using Newline for line ends.
public string GetSubstring(int startOffset, int substringLength)
Parameter | Type | Description |
---|---|---|
startOffset | Int32 | The offset at which to retrieve the text. |
substringLength | Int32 | The number of characters to return. |
Returns
Peek()
Peeks at a single character from the text buffer without seeking past it.
Peek(Int32)
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 | Int32 | 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.
Pop()
Pops the top offset from the stack and moves the Offset to that offset.
PopAll()
Pops the all offsets from the stack and moves the Offset to the offset that was on the bottom of the stack.
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.
ReadReverse()
Reverse reads a single character from the text buffer and seeks backward one offset.
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
- Boolean:
true
if the desired character was read; otherwise,false
if the start of the text buffer was reached.
ReadReverseThrough(Char, Int32)
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 | Int32 | The minimum offset to check. |
Returns
- Boolean:
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
- Boolean:
true
if the desired character was read; otherwise,false
if the end of the text buffer was reached.
ReadThrough(Char, Int32)
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 | Int32 | The maximum offset to check. |
Returns
- Boolean:
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.