Class TextPtr
A parser utility structure representing a pointer to a location within a string.
Inheritance
System.Object
TextPtr
Assembly: VRage.Game.dll
Syntax
public sealed class TextPtr : ValueType
Constructors
TextPtr(String)
Create a new text pointer at the first character in the given string
Declaration
public TextPtr(string content)
Parameters
Type |
Name |
Description |
System.String |
content |
|
TextPtr(String, Int32)
Create a new text pointer at the given index of the given string
Declaration
public TextPtr(string content, int index)
Parameters
Type |
Name |
Description |
System.String |
content |
|
System.Int32 |
index |
|
Fields
Content
The original content string
Declaration
public readonly string Content
Field Value
Type |
Description |
System.String |
|
Index
The index being pointed at by this structure
Declaration
public readonly int Index
Field Value
Type |
Description |
System.Int32 |
|
Properties
Char
Returns the character currently being pointed at, or \0
if out of bounds
Declaration
public char Char { get; }
Property Value
Type |
Description |
System.Char |
|
IsEmpty
Determines whether this pointer is an empty pointer, i.e. not pointing at anything at all.
Declaration
public bool IsEmpty { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
Find(Char)
Finds the given character
Declaration
public TextPtr Find(char ch)
Parameters
Type |
Name |
Description |
System.Char |
ch |
|
Returns
Find(String)
Finds the given text string
Declaration
public TextPtr Find(string str)
Parameters
Type |
Name |
Description |
System.String |
str |
|
Returns
FindAny(Char[])
Finds one of the given characters
Declaration
public TextPtr FindAny(char[] chs)
Parameters
Type |
Name |
Description |
System.Char[] |
chs |
|
Returns
FindAnyInLine(Char[])
Finds one of the given characters within the current line
Declaration
public TextPtr FindAnyInLine(char[] chs)
Parameters
Type |
Name |
Description |
System.Char[] |
chs |
|
Returns
FindEndOfLine(Boolean)
Finds the end of the current line
Declaration
public TextPtr FindEndOfLine(bool skipNewline = false)
Parameters
Type |
Name |
Description |
System.Boolean |
skipNewline |
Whether the actual newline character(s) should also be skipped. Defaults to false
|
Returns
FindInLine(Char)
Finds the given character within the current line
Declaration
public TextPtr FindInLine(char ch)
Parameters
Type |
Name |
Description |
System.Char |
ch |
|
Returns
FindLineNo()
Determines what line number this pointer is currently at.
Declaration
Returns
Type |
Description |
System.Int32 |
|
IsEndOfLine()
Determines whether the pointer is currently at the end of a line (right before a newline character set or end of the string)
Declaration
public bool IsEndOfLine()
Returns
Type |
Description |
System.Boolean |
|
IsNewLine()
Determines whether the pointer is currently at a newline (end of the string is not a newline)
Declaration
Returns
Type |
Description |
System.Boolean |
|
IsOutOfBounds()
Determines whether this pointer is currently out of bounds (before or after the string content)
Declaration
public bool IsOutOfBounds()
Returns
Type |
Description |
System.Boolean |
|
IsStartOfLine()
Determines whether the pointer is currently at the beginning of a line (right after a newline character set or start of the string)
Declaration
public bool IsStartOfLine()
Returns
Type |
Description |
System.Boolean |
|
SkipWhitespace(Boolean)
Declaration
public TextPtr SkipWhitespace(bool skipNewline = false)
Parameters
Type |
Name |
Description |
System.Boolean |
skipNewline |
Whether to also skip newlines
|
Returns
StartsWith(String)
Determines if the current pointer location starts with the given string - in a case sensitive manner.
Declaration
public bool StartsWith(string what)
Parameters
Type |
Name |
Description |
System.String |
what |
|
Returns
Type |
Description |
System.Boolean |
|
StartsWithCaseInsensitive(String)
Determines if the current pointer location starts with the given string - in a case insensitive manner.
Declaration
public bool StartsWithCaseInsensitive(string what)
Parameters
Type |
Name |
Description |
System.String |
what |
|
Returns
Type |
Description |
System.Boolean |
|
TrimEnd()
Reverses the pointer location until all whitespace is skipped - does not skip newlines
Declaration
Returns
TrimStart()
Advances the pointer location until all whitespace is skipped - does not skip newlines
Declaration
public TextPtr TrimStart()
Returns
Operators
Addition(TextPtr, Int32)
Add an offset to a pointer
Declaration
public static TextPtr operator +(TextPtr ptr, int offset)
Parameters
Type |
Name |
Description |
TextPtr |
ptr |
|
System.Int32 |
offset |
|
Returns
Decrement(TextPtr)
Decrement a pointer by one
Declaration
public static TextPtr operator --(TextPtr ptr)
Parameters
Returns
Implicit(TextPtr to Int32)
Implicitly return the index into the string
Declaration
public static implicit operator int (TextPtr ptr)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Implicit(TextPtr to String)
Implicitly return the original string
Declaration
public static implicit operator string (TextPtr ptr)
Parameters
Returns
Type |
Description |
System.String |
|
Increment(TextPtr)
Increment a pointer by one
Declaration
public static TextPtr operator ++(TextPtr ptr)
Parameters
Returns
Subtraction(TextPtr, Int32)
Subtract an offset from a pointer
Declaration
public static TextPtr operator -(TextPtr ptr, int offset)
Parameters
Type |
Name |
Description |
TextPtr |
ptr |
|
System.Int32 |
offset |
|
Returns