Struct NativeText.ReadOnly
A read-only alias for the value of a NativeText. Does not have its own allocated storage.
Namespace: Unity.Collections
Assembly: Unity.Collections.dll
Syntax
[NativeContainer]
[NativeContainerIsReadOnly]
public struct NativeText.ReadOnly : INativeList<byte>, IIndexable<byte>, IUTF8Bytes
Properties
Capacity
The current capacity in bytes of this string.
Declaration
public int Capacity { readonly get; set; }
Property Value
Type | Description |
---|---|
int | The current capacity in bytes of the string. |
Remarks
The null-terminator byte is not included in the capacity, so the string's character buffer is Capacity + 1
in size.
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined and a write is attempted. |
IsEmpty
Whether this string has no characters.
Declaration
public bool IsEmpty { readonly get; set; }
Property Value
Type | Description |
---|---|
bool | True if this string has no characters or if the string has not been constructed. |
this[int]
The byte at an index.
Declaration
public byte this[int index] { readonly get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | A zero-based byte index. |
Property Value
Type | Description |
---|---|
byte | The byte at the index. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the index is out of bounds. |
NotSupportedException | Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined and a write is attempted. |
Length
The current length in bytes of this string.
Declaration
public int Length { readonly get; set; }
Property Value
Type | Description |
---|---|
int | The current length in bytes of the UTF-8 encoded string. |
Remarks
The length does not include the null terminator byte.
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined and a write is attempted. |
Methods
Clear()
Sets the length to 0. For a NativeText.Readonly this function does nothing, unless safety checks are enabled (in which case it throws).
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined. |
CompareTo(string)
Returns the lexicographical sort order of this string relative to another.
Declaration
[ExcludeFromBurstCompatTesting("Takes managed string")]
public int CompareTo(string other)
Parameters
Type | Name | Description |
---|---|---|
string | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(FixedString128Bytes)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(FixedString128Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString128Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(FixedString32Bytes)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(FixedString32Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString32Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(FixedString4096Bytes)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(FixedString4096Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString4096Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(FixedString512Bytes)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(FixedString512Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString512Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(FixedString64Bytes)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(FixedString64Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString64Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(NativeText)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(NativeText other)
Parameters
Type | Name | Description |
---|---|---|
NativeText | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
CompareTo(ReadOnly)
Returns the lexicographical sort order of this string relative to another.
Declaration
public int CompareTo(NativeText.ReadOnly other)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | other | Another string to compare with. |
Returns
Type | Description |
---|---|
int | A number denoting the lexicographical sort order of this string relative to the other string:
|
ElementAt(int)
Returns a reference to the byte (not character) at an index. Unsupported by NativeText.ReadOnly.
Declaration
public ref byte ElementAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | A byte index. |
Returns
Type | Description |
---|---|
byte | A reference to the byte at the index. |
Remarks
This function is a no-op when ENABLE_UNITY_COLLECTIONS_CHECKS is not defined, throws otherwise.
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown when called. This operation is not supported. |
Equals(object)
Returns true if this string and another object are equal.
Declaration
[ExcludeFromBurstCompatTesting("Takes managed object")]
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
object | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if this string and the object are equal. |
Overrides
Remarks
For the object to be equal, it must itself be a managed string, NativeText, or FixedStringNBytes.
Two strings are equal if they have equal length and all their characters match.
Equals(string)
Returns true if this string and another are equal.
Declaration
[ExcludeFromBurstCompatTesting("Takes managed string")]
public bool Equals(string other)
Parameters
Type | Name | Description |
---|---|---|
string | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(FixedString128Bytes)
Returns true if this string and another are equal.
Declaration
public bool Equals(FixedString128Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString128Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(FixedString32Bytes)
Returns true if this string and another are equal.
Declaration
public bool Equals(FixedString32Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString32Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(FixedString4096Bytes)
Returns true if this string and another are equal.
Declaration
public bool Equals(FixedString4096Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString4096Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(FixedString512Bytes)
Returns true if this string and another are equal.
Declaration
public bool Equals(FixedString512Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString512Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(FixedString64Bytes)
Returns true if this string and another are equal.
Declaration
public bool Equals(FixedString64Bytes other)
Parameters
Type | Name | Description |
---|---|---|
FixedString64Bytes | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(NativeText)
Returns true if this string and another are equal.
Declaration
public bool Equals(NativeText other)
Parameters
Type | Name | Description |
---|---|---|
NativeText | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
Equals(ReadOnly)
Returns true if this string and another are equal.
Declaration
public bool Equals(NativeText.ReadOnly other)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | other | Another string to compare with. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
GetEnumerator()
Returns an enumerator for iterating over the characters of the NativeText.
Declaration
public NativeText.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
NativeText.Enumerator | An enumerator for iterating over the characters of the NativeText. |
GetHashCode()
Returns a hash code of this string.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code of this string. |
Overrides
Remarks
The hash code is an integer that is always the same for two equal strings but (very likely) different for two unequal strings.
GetUnsafePtr()
Returns a pointer to this string's character buffer.
Declaration
public byte* GetUnsafePtr()
Returns
Type | Description |
---|---|
byte* | A pointer to this string's character buffer. |
Remarks
The pointer is made invalid by operations that reallocate the character buffer, such as setting Capacity.
ToString()
Returns a managed string copy of this string.
Declaration
[ExcludeFromBurstCompatTesting("Returns managed string")]
public override string ToString()
Returns
Type | Description |
---|---|
string | A managed string copy of this string. |
Overrides
TryResize(int, NativeArrayOptions)
Attempt to set the length in bytes of this string. For NativeText.ReadOnly this function is a no-op and always returns false.
Declaration
public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
Parameters
Type | Name | Description |
---|---|---|
int | newLength | The new length in bytes of the string. |
NativeArrayOptions | clearOptions | Whether any bytes added should be zeroed out. |
Returns
Type | Description |
---|---|
bool | Always false. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined. |
Operators
operator ==(in ReadOnly, in FixedString128Bytes)
Returns true if two strings are equal.
Declaration
public static bool operator ==(in NativeText.ReadOnly a, in FixedString128Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString128Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator ==(in ReadOnly, in FixedString32Bytes)
Returns true if two strings are equal.
Declaration
public static bool operator ==(in NativeText.ReadOnly a, in FixedString32Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString32Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator ==(in ReadOnly, in FixedString4096Bytes)
Returns true if two strings are equal.
Declaration
public static bool operator ==(in NativeText.ReadOnly a, in FixedString4096Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString4096Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator ==(in ReadOnly, in FixedString512Bytes)
Returns true if two strings are equal.
Declaration
public static bool operator ==(in NativeText.ReadOnly a, in FixedString512Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString512Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator ==(in ReadOnly, in FixedString64Bytes)
Returns true if two strings are equal.
Declaration
public static bool operator ==(in NativeText.ReadOnly a, in FixedString64Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString64Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are equal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator !=(in ReadOnly, in FixedString128Bytes)
Returns true if two strings are unequal.
Declaration
public static bool operator !=(in NativeText.ReadOnly a, in FixedString128Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString128Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are unequal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator !=(in ReadOnly, in FixedString32Bytes)
Returns true if two strings are unequal.
Declaration
public static bool operator !=(in NativeText.ReadOnly a, in FixedString32Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString32Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are unequal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator !=(in ReadOnly, in FixedString4096Bytes)
Returns true if two strings are unequal.
Declaration
public static bool operator !=(in NativeText.ReadOnly a, in FixedString4096Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString4096Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are unequal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator !=(in ReadOnly, in FixedString512Bytes)
Returns true if two strings are unequal.
Declaration
public static bool operator !=(in NativeText.ReadOnly a, in FixedString512Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString512Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are unequal. |
Remarks
Two strings are equal if they have equal length and all their characters match.
operator !=(in ReadOnly, in FixedString64Bytes)
Returns true if two strings are unequal.
Declaration
public static bool operator !=(in NativeText.ReadOnly a, in FixedString64Bytes b)
Parameters
Type | Name | Description |
---|---|---|
NativeText.ReadOnly | a | A string to compare. |
FixedString64Bytes | b | Another string to compare. |
Returns
Type | Description |
---|---|
bool | True if the two strings are unequal. |
Remarks
Two strings are equal if they have equal length and all their characters match.