Photon Fusion 2.1.1

NetworkString< TSize > Struct Template Reference

Fixed-size UTF32 string. All operations are alloc-free, except for converting to System.String. More...

Inherits , and INetworkStruct.

Public Member Functions

void Assign (string value)
 Assign a new value to this NetworkString.
readonly int Compare (NetworkString< TSize > s)
 Compares this instance with a specified NetworkString.
readonly int Compare (ref NetworkString< TSize > s)
 Compares this instance with a specified NetworkString.
readonly int Compare (string s)
 Compares this instance with a specified string.
readonly int Compare< TOtherSize > (NetworkString< TOtherSize > other)
 Compares this instance with a specified NetworkString of a different size.
readonly int Compare< TOtherSize > (ref NetworkString< TOtherSize > other)
 Compares this instance with a specified NetworkString of a different size.
bool Contains (char c)
 Determines whether a specified character is in this instance.
bool Contains (string str)
 Determines whether a specified string is in this instance.
bool Contains (uint codePoint)
 Determines whether a specified Unicode code point is in this instance.
bool Contains< TOtherSize > (NetworkString< TOtherSize > str)
 Determines whether a specified NetworkString is in this instance.
bool Contains< TOtherSize > (ref NetworkString< TOtherSize > str)
 Determines whether a specified NetworkString is in this instance.
bool EndsWith (string s)
 Checks if the current NetworkString ends with a specified string.
bool EndsWith< TOtherSize > (ref NetworkString< TOtherSize > other)
 Checks if the current NetworkString ends with a specified NetworkString of a different size.
readonly bool Equals (NetworkString< TSize > other)
 Determines whether the current NetworkString is equal to a specified NetworkString.
override bool Equals (object obj)
 Determines whether the current NetworkString is equal to a specified object.
readonly bool Equals (ref NetworkString< TSize > other)
 Determines whether the current NetworkString is equal to a specified NetworkString.
readonly bool Equals (string s)
 Determines whether the current NetworkString is equal to a specified string.
readonly bool Equals< TOtherSize > (NetworkString< TOtherSize > other)
 Determines whether the current NetworkString is equal to a specified NetworkString of a different size.
readonly bool Equals< TOtherSize > (ref NetworkString< TOtherSize > other)
 Determines whether the current NetworkString is equal to a specified NetworkString of a different size.
readonly bool Get (ref string cache)
 Checks if cache is equivalent and if not converts to UTF16 and stores the result in cache .
int GetCharCount ()
 Calculates the length of the equivalent UTF16 string.
UTF32Tools.CharEnumerator GetEnumerator ()
 Returns an enumerator that iterates through the NetworkString.
override readonly int GetHashCode ()
 Returns the hash code for this NetworkString.
int IndexOf (char c, int startIndex, int count)
 Returns the index of the first occurrence of a specified character in this instance.
int IndexOf (char c, int startIndex=0)
 Returns the index of the first occurrence of a specified character in this instance.
int IndexOf (string str, int startIndex, int count)
 Returns the index of the first occurrence of a specified string in this instance.
int IndexOf (string str, int startIndex=0)
 Returns the index of the first occurrence of a specified string in this instance.
int IndexOf (uint codePoint, int startIndex, int count)
 Returns the index of the first occurrence of a specified Unicode code point in this instance.
int IndexOf (uint codePoint, int startIndex=0)
 Returns the index of the first occurrence of a specified Unicode code point in this instance.
int IndexOf< TOtherSize > (NetworkString< TOtherSize > str, int startIndex, int count)
 Returns the index of the first occurrence of a specified NetworkString in this instance.
int IndexOf< TOtherSize > (NetworkString< TOtherSize > str, int startIndex=0)
 Returns the index of the first occurrence of a specified NetworkString in this instance.
int IndexOf< TOtherSize > (ref NetworkString< TOtherSize > str, int startIndex, int count)
 Returns the index of the first occurrence of a specified NetworkString in this instance.
int IndexOf< TOtherSize > (ref NetworkString< TOtherSize > str, int startIndex=0)
 Returns the index of the first occurrence of a specified NetworkString in this instance.
 NetworkString (int length, uint[] data)
 Creates a new instance of NetworkString<Size> with the given value.
 NetworkString (string value)
 Creates a new instance of NetworkString<Size> with the given value.
void IReadOnlySpanAssignable. Set (ReadOnlySpan< uint > values)
 Initializes the fixed storage with the specified values.
Parameters
values

bool Set (string value)
 Converts value to UTF32 string and stores it internally.
bool StartsWith (string s)
 Checks if the current NetworkString starts with a specified string.
bool StartsWith< TOtherSize > (ref NetworkString< TOtherSize > other)
 Checks if the current NetworkString starts with a specified NetworkString of a different size.
NetworkString< TSize > Substring (int startIndex)
 Returns a substring from this instance. The substring starts at a specified character position.
NetworkString< TSize > Substring (int startIndex, int length)
 Returns a substring from this instance. The substring starts at a specified character position and has a specified length.
NetworkString< TSize > ToLower ()
 Converts all the characters in this NetworkString to lowercase.
override readonly string ToString ()
 Converts the value of this NetworkString to its equivalent string representation.
NetworkString< TSize > ToUpper ()
 Converts all the characters in this NetworkString to uppercase.

Static Public Member Functions

static implicit operator NetworkString< TSize > (string str)
 Defines an implicit conversion of a string to a NetworkString.
static operator string (NetworkString< TSize > str)
 Defines an explicit conversion of a NetworkString to a string.
static bool operator!= (NetworkString< TSize > a, NetworkString< TSize > b)
 Defines an inequality operator for NetworkString.
static bool operator!= (NetworkString< TSize > a, string b)
 Defines an inequality operator for a NetworkString and a string.
static bool operator!= (string a, NetworkString< TSize > b)
 Defines an inequality operator for a string and a NetworkString.
static bool operator== (NetworkString< TSize > a, NetworkString< TSize > b)
 Defines an equality operator for NetworkString.
static bool operator== (NetworkString< TSize > a, string b)
 Defines an equality operator for a NetworkString and a string.
static bool operator== (string a, NetworkString< TSize > b)
 Defines an equality operator for a string and a NetworkString.

Properties

readonly int Capacity [get]
 Maximum UTF32 string length.
readonly int Length [get]
 Number of UTF32 scalars. It is equal or less than GetCharCount or the length of Value, because those use UTF16 encoding, which needs two characters to encode some values.
ref uint this[int index] [get]
 Returns UTF32 scalar at index position. To iterate over characters, use GetEnumerator.
string Value [get, set]
 Converts to/from regular UTF16 string. Setter is alloc-free. Use Get to get possibly alloc-free conversion.

Detailed Description

Fixed-size UTF32 string. All operations are alloc-free, except for converting to System.String.

Template Parameters
TSize
Type Constraints
TSize :unmanaged 
TSize :IFixedStorage 

Member Function Documentation

◆ Assign()

void Assign ( string value)

Assign a new value to this NetworkString.

Parameters
valueString value.

◆ Compare() [1/3]

readonly int Compare ( NetworkString< TSize > s)

Compares this instance with a specified NetworkString.

Parameters
sThe NetworkString to compare.
Returns
A 32-bit signed integer that indicates the comparison result.

◆ Compare() [2/3]

readonly int Compare ( ref NetworkString< TSize > s)

Compares this instance with a specified NetworkString.

Parameters
sThe NetworkString to compare.
Returns
A 32-bit signed integer that indicates the comparison result.

◆ Compare() [3/3]

readonly int Compare ( string s)

Compares this instance with a specified string.

Parameters
sThe string to compare.
Returns
A 32-bit signed integer that indicates the comparison result.

◆ Compare< TOtherSize >() [1/2]

readonly int Compare< TOtherSize > ( NetworkString< TOtherSize > other)

Compares this instance with a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to compare.
Returns
A 32-bit signed integer that indicates the comparison result.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Compare< TOtherSize >() [2/2]

readonly int Compare< TOtherSize > ( ref NetworkString< TOtherSize > other)

Compares this instance with a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to compare.
Returns
A 32-bit signed integer that indicates the comparison result.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Contains() [1/3]

bool Contains ( char c)

Determines whether a specified character is in this instance.

Parameters
cThe Unicode character to seek.
Returns
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

◆ Contains() [2/3]

bool Contains ( string str)

Determines whether a specified string is in this instance.

Parameters
strThe string to seek.
Returns
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

◆ Contains() [3/3]

bool Contains ( uint codePoint)

Determines whether a specified Unicode code point is in this instance.

Parameters
codePointThe Unicode code point to seek.
Returns
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

◆ Contains< TOtherSize >() [1/2]

bool Contains< TOtherSize > ( NetworkString< TOtherSize > str)

Determines whether a specified NetworkString is in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
Returns
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Contains< TOtherSize >() [2/2]

bool Contains< TOtherSize > ( ref NetworkString< TOtherSize > str)

Determines whether a specified NetworkString is in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
Returns
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ EndsWith()

bool EndsWith ( string s)

Checks if the current NetworkString ends with a specified string.

Parameters
sThe string to check.
Returns
true if the current NetworkString ends with the specified string; otherwise, false.
Exceptions
ArgumentNullExceptionThrown when the string is null.

◆ EndsWith< TOtherSize >()

bool EndsWith< TOtherSize > ( ref NetworkString< TOtherSize > other)

Checks if the current NetworkString ends with a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to check.
Returns
true if the current NetworkString ends with the specified NetworkString; otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Equals() [1/4]

readonly bool Equals ( NetworkString< TSize > other)

Determines whether the current NetworkString is equal to a specified NetworkString.

Parameters
otherThe NetworkString to compare with the current NetworkString.
Returns
true if the specified NetworkString is equal to the current NetworkString; otherwise, false.

◆ Equals() [2/4]

override bool Equals ( object obj)

Determines whether the current NetworkString is equal to a specified object.

Parameters
objThe object to compare with the current NetworkString.
Returns
true if the specified object is equal to the current NetworkString; otherwise, false.

◆ Equals() [3/4]

readonly bool Equals ( ref NetworkString< TSize > other)

Determines whether the current NetworkString is equal to a specified NetworkString.

Parameters
otherThe NetworkString to compare with the current NetworkString.
Returns
true if the specified NetworkString is equal to the current NetworkString; otherwise, false.

◆ Equals() [4/4]

readonly bool Equals ( string s)

Determines whether the current NetworkString is equal to a specified string.

Parameters
sThe string to compare with the current NetworkString.
Returns
true if the specified string is equal to the current NetworkString; otherwise, false.

◆ Equals< TOtherSize >() [1/2]

readonly bool Equals< TOtherSize > ( NetworkString< TOtherSize > other)

Determines whether the current NetworkString is equal to a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to compare with the current NetworkString.
Returns
true if the specified NetworkString is equal to the current NetworkString; otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Equals< TOtherSize >() [2/2]

readonly bool Equals< TOtherSize > ( ref NetworkString< TOtherSize > other)

Determines whether the current NetworkString is equal to a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to compare with the current NetworkString.
Returns
true if the specified NetworkString is equal to the current NetworkString; otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Get()

readonly bool Get ( ref string cache)

Checks if cache is equivalent and if not converts to UTF16 and stores the result in cache .

Parameters
cacheThe string to convert.
Returns
False if no conversion was performed, true otherwise.

◆ GetCharCount()

int GetCharCount ( )

Calculates the length of the equivalent UTF16 string.

Returns
The length of the equivalent UTF16 string.

◆ GetEnumerator()

UTF32Tools.CharEnumerator GetEnumerator ( )

Returns an enumerator that iterates through the NetworkString.

Returns
A UTF32Tools.CharEnumerator for the NetworkString.

◆ GetHashCode()

override readonly int GetHashCode ( )

Returns the hash code for this NetworkString.

Returns
A 32-bit signed integer hash code.

◆ IndexOf() [1/6]

int IndexOf ( char c,
int startIndex,
int count )

Returns the index of the first occurrence of a specified character in this instance.

Parameters
cThe Unicode character to seek.
startIndexThe search starting position.
countThe number of character positions to examine.
Returns
The zero-based index position of value if that character is found, or -1 if it is not.

◆ IndexOf() [2/6]

int IndexOf ( char c,
int startIndex = 0 )

Returns the index of the first occurrence of a specified character in this instance.

Parameters
cThe Unicode character to seek.
startIndexThe search starting position.
Returns
The zero-based index position of value if that character is found, or -1 if it is not.

◆ IndexOf() [3/6]

int IndexOf ( string str,
int startIndex,
int count )

Returns the index of the first occurrence of a specified string in this instance.

Parameters
strThe string to seek.
startIndexThe search starting position.
countThe number of character positions to examine.
Returns
The zero-based index position of value if that string is found, or -1 if it is not.
Exceptions
ArgumentNullExceptionThrown when the string is null.
ArgumentOutOfRangeExceptionThrown when the start index is less than zero or greater than the safe length of the string, or when the count is less than zero or the sum of the start index and count is greater than the safe length of the string.

◆ IndexOf() [4/6]

int IndexOf ( string str,
int startIndex = 0 )

Returns the index of the first occurrence of a specified string in this instance.

Parameters
strThe string to seek.
startIndexThe search starting position.
Returns
The zero-based index position of value if that string is found, or -1 if it is not.

◆ IndexOf() [5/6]

int IndexOf ( uint codePoint,
int startIndex,
int count )

Returns the index of the first occurrence of a specified Unicode code point in this instance.

Parameters
codePointThe Unicode code point to seek.
startIndexThe search starting position.
countThe number of character positions to examine.
Returns
The zero-based index position of value if that Unicode code point is found, or -1 if it is not.
Exceptions
ArgumentOutOfRangeExceptionThrown when the start index is less than zero or greater than the safe length of the string, or when the count is less than zero or the sum of the start index and count is greater than the safe length of the string.

◆ IndexOf() [6/6]

int IndexOf ( uint codePoint,
int startIndex = 0 )

Returns the index of the first occurrence of a specified Unicode code point in this instance.

Parameters
codePointThe Unicode code point to seek.
startIndexThe search starting position.
Returns
The zero-based index position of value if that Unicode code point is found, or -1 if it is not.

◆ IndexOf< TOtherSize >() [1/4]

int IndexOf< TOtherSize > ( NetworkString< TOtherSize > str,
int startIndex,
int count )

Returns the index of the first occurrence of a specified NetworkString in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
startIndexThe search starting position.
countThe number of character positions to examine.
Returns
The zero-based index position of value if that NetworkString is found, or -1 if it is not.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ IndexOf< TOtherSize >() [2/4]

int IndexOf< TOtherSize > ( NetworkString< TOtherSize > str,
int startIndex = 0 )

Returns the index of the first occurrence of a specified NetworkString in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
startIndexThe search starting position.
Returns
The zero-based index position of value if that NetworkString is found, or -1 if it is not.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ IndexOf< TOtherSize >() [3/4]

int IndexOf< TOtherSize > ( ref NetworkString< TOtherSize > str,
int startIndex,
int count )

Returns the index of the first occurrence of a specified NetworkString in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
startIndexThe search starting position.
countThe number of character positions to examine.
Returns
The zero-based index position of value if that NetworkString is found, or -1 if it is not.
Exceptions
ArgumentOutOfRangeExceptionThrown when the start index is less than zero or greater than the safe length of the string, or when the count is less than zero or the sum of the start index and count is greater than the safe length of the string.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ IndexOf< TOtherSize >() [4/4]

int IndexOf< TOtherSize > ( ref NetworkString< TOtherSize > str,
int startIndex = 0 )

Returns the index of the first occurrence of a specified NetworkString in this instance.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
strThe NetworkString to seek.
startIndexThe search starting position.
Returns
The zero-based index position of value if that NetworkString is found, or -1 if it is not.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ NetworkString() [1/2]

NetworkString ( int length,
uint[] data )

Creates a new instance of NetworkString<Size> with the given value.

Parameters
length
data

◆ NetworkString() [2/2]

NetworkString ( string value)

Creates a new instance of NetworkString<Size> with the given value.

Parameters
valueString value.

◆ operator NetworkString< TSize >()

implicit operator NetworkString< TSize > ( string str)
static

Defines an implicit conversion of a string to a NetworkString.

Parameters
strThe string to convert.
Returns
A new instance of NetworkString with the same value as the string.

◆ operator string()

operator string ( NetworkString< TSize > str)
explicitstatic

Defines an explicit conversion of a NetworkString to a string.

Parameters
strThe NetworkString to convert.
Returns
The string value of the NetworkString.

◆ operator!=() [1/3]

bool operator!= ( NetworkString< TSize > a,
NetworkString< TSize > b )
static

Defines an inequality operator for NetworkString.

Parameters
aThe first NetworkString to compare.
bThe second NetworkString to compare.
Returns
true if the NetworkStrings are not equal; otherwise, false.

◆ operator!=() [2/3]

bool operator!= ( NetworkString< TSize > a,
string b )
static

Defines an inequality operator for a NetworkString and a string.

Parameters
aThe NetworkString to compare.
bThe string to compare.
Returns
true if the NetworkString and the string are not equal; otherwise, false.

◆ operator!=() [3/3]

bool operator!= ( string a,
NetworkString< TSize > b )
static

Defines an inequality operator for a string and a NetworkString.

Parameters
aThe string to compare.
bThe NetworkString to compare.
Returns
true if the string and the NetworkString are not equal; otherwise, false.

◆ operator==() [1/3]

bool operator== ( NetworkString< TSize > a,
NetworkString< TSize > b )
static

Defines an equality operator for NetworkString.

Parameters
aThe first NetworkString to compare.
bThe second NetworkString to compare.
Returns
true if the NetworkStrings are equal; otherwise, false.

◆ operator==() [2/3]

bool operator== ( NetworkString< TSize > a,
string b )
static

Defines an equality operator for a NetworkString and a string.

Parameters
aThe NetworkString to compare.
bThe string to compare.
Returns
true if the NetworkString and the string are equal; otherwise, false.

◆ operator==() [3/3]

bool operator== ( string a,
NetworkString< TSize > b )
static

Defines an equality operator for a string and a NetworkString.

Parameters
aThe string to compare.
bThe NetworkString to compare.
Returns
true if the string and the NetworkString are equal; otherwise, false.

◆ Set()

bool Set ( string value)

Converts value to UTF32 string and stores it internally.

Parameters
valueThe string to set.
Returns
False if value was too long to fit and had to be trimmed.

◆ StartsWith()

bool StartsWith ( string s)

Checks if the current NetworkString starts with a specified string.

Parameters
sThe string to check.
Returns
true if the current NetworkString starts with the specified string; otherwise, false.
Exceptions
ArgumentNullExceptionThrown when the string is null.

◆ StartsWith< TOtherSize >()

bool StartsWith< TOtherSize > ( ref NetworkString< TOtherSize > other)

Checks if the current NetworkString starts with a specified NetworkString of a different size.

Template Parameters
TOtherSizeThe size of the other NetworkString.
Parameters
otherThe NetworkString to check.
Returns
true if the current NetworkString starts with the specified NetworkString; otherwise, false.
Type Constraints
TOtherSize :unmanaged 
TOtherSize :IFixedStorage 

◆ Substring() [1/2]

NetworkString< TSize > Substring ( int startIndex)

Returns a substring from this instance. The substring starts at a specified character position.

Parameters
startIndexThe zero-based starting character position of a substring in this instance.
Returns
A new NetworkString that is equivalent to the substring that begins at startIndex in this instance, or NetworkString.Empty if startIndex is equal to the length of this instance.
Exceptions
ArgumentOutOfRangeExceptionstartIndex is less than zero or greater than the length of this instance.

◆ Substring() [2/2]

NetworkString< TSize > Substring ( int startIndex,
int length )

Returns a substring from this instance. The substring starts at a specified character position and has a specified length.

Parameters
startIndexThe zero-based starting character position of a substring in this instance.
lengthThe number of characters in the substring.
Returns
A new NetworkString that is equivalent to the substring of length length that begins at startIndex in this instance, or NetworkString.Empty if startIndex is equal to the length of this instance and length is zero.
Exceptions
ArgumentOutOfRangeExceptionstartIndex plus length indicates a position not within this instance, or startIndex or length is less than zero.

◆ ToLower()

NetworkString< TSize > ToLower ( )

Converts all the characters in this NetworkString to lowercase.

Returns
A new NetworkString in which all characters in this NetworkString are converted to lowercase.

◆ ToString()

override readonly string ToString ( )

Converts the value of this NetworkString to its equivalent string representation.

Returns
A string representation of the value of this NetworkString.

◆ ToUpper()

NetworkString< TSize > ToUpper ( )

Converts all the characters in this NetworkString to uppercase.

Returns
A new NetworkString in which all characters in this NetworkString are converted to uppercase.

Property Documentation

◆ this[int index]

ref uint this[int index]
get

Returns UTF32 scalar at index position. To iterate over characters, use GetEnumerator.

Parameters
indexIndex to get.
Returns
UTF32 scalar at index position.