Class StringReader
Namespace: Void.Minecraft.Commands.Brigadier
Assembly: Void.Minecraft.dll
Provides cursor-based parsing primitives for Brigadier command input.
public class StringReader : IImmutableStringReaderInheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
StringReader(string, int)
Provides cursor-based parsing primitives for Brigadier command input.
public StringReader(string source, int cursor = 0)Parameters
source string
The complete command input.
cursor int
The initial zero-based cursor.
StringReader(StringReader)
Creates a reader with the same source and cursor as another reader.
public StringReader(StringReader reader)Parameters
reader StringReader
The reader state to copy.
Properties
CanRead
Gets whether at least one character can be read.
public bool CanRead { get; }Property Value
Cursor
Gets or sets the zero-based cursor.
public int Cursor { get; set; }Property Value
Peek
Gets the character at the current cursor without advancing it.
public char Peek { get; }Property Value
Read
Gets the source prefix before the cursor.
public string Read { get; }Property Value
Remaining
Gets the source suffix beginning at the cursor.
public string Remaining { get; }Property Value
RemainingLength
Gets the number of characters from the cursor through the end.
public int RemainingLength { get; }Property Value
Source
Gets the complete source string.
public string Source { get; init; }Property Value
TotalLength
Gets the total source length.
public int TotalLength { get; }Property Value
Methods
CanReadLength(int)
Determines whether advancing the cursor by length characters remains within the source.
public bool CanReadLength(int length)Parameters
length int
The number of characters to test from the current cursor position.
Returns
true when length characters can be read without moving past
Expect(char)
Consumes an expected character.
public void Expect(char character)Parameters
character char
The required next character.
Exceptions
The source ended or the next character differs.
IsAllowedInUnquotedString(char)
Determines whether a character is accepted in an unquoted argument token.
public static bool IsAllowedInUnquotedString(char character)Parameters
character char
The character to test.
Returns
true for an ASCII letter, digit, underscore, hyphen, period, or plus.
IsAllowedNumber(char)
Determines whether a character may be consumed as part of a numeric token.
public static bool IsAllowedNumber(char digit)Parameters
digit char
The character to test.
Returns
true for an ASCII digit, period, or hyphen.
IsQuotedStringStart(char)
Determines whether a character opens a quoted string.
public static bool IsQuotedStringStart(char character)Parameters
character char
The character to test.
Returns
true for a single or double quote.
PeekAt(int)
Gets a character at an offset from the cursor without advancing it.
public char PeekAt(int offset)Parameters
offset int
The relative character offset.
Returns
The selected character.
ReadBoolean()
Reads a quoted or unquoted Boolean token.
public bool ReadBoolean()Returns
The parsed Boolean.
Exceptions
No token is present or the token is not true or false.
ReadDouble()
Reads a double-precision token using the current culture.
public double ReadDouble()Returns
The parsed value.
Exceptions
No numeric token is present or it is not a valid double.
ReadFloat()
Reads a single-precision token using the current culture.
public float ReadFloat()Returns
The parsed value.
Exceptions
No numeric token is present or it is not a valid float.
ReadInt()
Reads a signed 32-bit integer token using the current culture.
public int ReadInt()Returns
The parsed integer.
Exceptions
No numeric token is present or it is not a valid integer.
ReadLong()
Reads a signed 64-bit integer token using the current culture.
public long ReadLong()Returns
The parsed long integer.
Exceptions
No numeric token is present or it is not a valid long integer.
ReadNext()
Returns the current character and advances the cursor by one.
public char ReadNext()Returns
The consumed character.
ReadQuotedString()
Reads a single- or double-quoted string including escape processing.
public string ReadQuotedString()Returns
The unescaped contents, or an empty string at end of input.
Exceptions
The next character is not a quote, an escape is invalid, or the quote is unclosed.
ReadString()
Reads either a quoted string or an unquoted token according to the next character.
public string ReadString()Returns
The parsed string, or an empty string at end of input.
Exceptions
A quoted token contains an invalid escape or is unclosed.
ReadStringUntil(char)
Reads through an unescaped terminator and processes backslash escapes.
public string ReadStringUntil(char terminator)Parameters
terminator char
The quote character that ends the string.
Returns
The unescaped contents without the terminator.
Exceptions
An escape targets an unsupported character or the terminator is absent.
ReadUnquotedString()
Reads consecutive characters accepted by
public string ReadUnquotedString()Returns
The consumed string, which may be empty.
Skip()
Advances the cursor by one without reading the character.
public void Skip()SkipWhitespace()
Advances past consecutive Unicode whitespace characters.
public void SkipWhitespace()