Skip to content

Class StringRange

Namespace: Void.Minecraft.Commands.Brigadier.Context
Assembly: Void.Minecraft.dll

Represents a half-open character range in command input.

public record StringRange : IEquatable<StringRange>

Inheritance

objectStringRange

Implements

IEquatable<StringRange>

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

StringRange(int, int)

Represents a half-open character range in command input.

public StringRange(int Start, int End)

Parameters

Start int

The inclusive start index.

End int

The exclusive end index.

Properties

End

The exclusive end index.

public int End { get; init; }

Property Value

int

IsEmpty

Gets whether the range has zero length.

public bool IsEmpty { get; }

Property Value

bool

Length

Gets minus .

public int Length { get; }

Property Value

int

Start

The inclusive start index.

public int Start { get; init; }

Property Value

int

Methods

At(int)

Creates an empty range at a position.

public static StringRange At(int pos)

Parameters

pos int

The start and end position.

Returns

StringRange

The empty range.

Between(int, int)

Creates a range between two supplied indexes without validation.

public static StringRange Between(int start, int end)

Parameters

start int

The inclusive start.

end int

The exclusive end.

Returns

StringRange

The range.

Encompassing(StringRange, StringRange)

Creates the smallest range containing two ranges.

public static StringRange Encompassing(StringRange a, StringRange b)

Parameters

a StringRange

The first range.

b StringRange

The second range.

Returns

StringRange

A range from the lesser start through the greater end.

Get(IImmutableStringReader)

Extracts this range from a reader’s source.

public string Get(IImmutableStringReader reader)

Parameters

reader IImmutableStringReader

The source provider.

Returns

string

The selected substring.

Get(string)

Extracts this range from a string.

public string Get(string value)

Parameters

value string

The source string.

Returns

string

The selected substring.