Show / Hide Table of Contents

Class TextPtr

A parser utility structure representing a pointer to a location within a string.

Inheritance
System.Object
TextPtr
Namespace: VRage.Game.ModAPI.Ingame.Utilities
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
Type Description
TextPtr

Find(String)

Finds the given text string

Declaration
public TextPtr Find(string str)
Parameters
Type Name Description
System.String str
Returns
Type Description
TextPtr

FindAny(Char[])

Finds one of the given characters

Declaration
public TextPtr FindAny(char[] chs)
Parameters
Type Name Description
System.Char[] chs
Returns
Type Description
TextPtr

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
Type Description
TextPtr

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
Type Description
TextPtr

FindInLine(Char)

Finds the given character within the current line

Declaration
public TextPtr FindInLine(char ch)
Parameters
Type Name Description
System.Char ch
Returns
Type Description
TextPtr

FindLineNo()

Determines what line number this pointer is currently at.

Declaration
public int FindLineNo()
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
public bool IsNewLine()
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)

Skips whitespace

Declaration
public TextPtr SkipWhitespace(bool skipNewline = false)
Parameters
Type Name Description
System.Boolean skipNewline

Whether to also skip newlines

Returns
Type Description
TextPtr

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
public TextPtr TrimEnd()
Returns
Type Description
TextPtr

TrimStart()

Advances the pointer location until all whitespace is skipped - does not skip newlines

Declaration
public TextPtr TrimStart()
Returns
Type Description
TextPtr

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
Type Description
TextPtr

Decrement(TextPtr)

Decrement a pointer by one

Declaration
public static TextPtr operator --(TextPtr ptr)
Parameters
Type Name Description
TextPtr ptr
Returns
Type Description
TextPtr

Implicit(TextPtr to Int32)

Implicitly return the index into the string

Declaration
public static implicit operator int (TextPtr ptr)
Parameters
Type Name Description
TextPtr ptr
Returns
Type Description
System.Int32

Implicit(TextPtr to String)

Implicitly return the original string

Declaration
public static implicit operator string (TextPtr ptr)
Parameters
Type Name Description
TextPtr ptr
Returns
Type Description
System.String

Increment(TextPtr)

Increment a pointer by one

Declaration
public static TextPtr operator ++(TextPtr ptr)
Parameters
Type Name Description
TextPtr ptr
Returns
Type Description
TextPtr

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
Type Description
TextPtr
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾