docs.unity.cn
    Show / Hide Table of Contents

    Struct NativeText.ReadOnly

    Namespace: Unity.Collections
    Syntax
    [NativeContainer]
    [NativeContainerIsReadOnly]
    public struct ReadOnly : INativeList<byte>, IIndexable<byte>, IUTF8Bytes, IComparable<string>, IEquatable<string>, IComparable<NativeText>, IEquatable<NativeText>, IComparable<FixedString32Bytes>, IEquatable<FixedString32Bytes>, IComparable<FixedString64Bytes>, IEquatable<FixedString64Bytes>, IComparable<FixedString128Bytes>, IEquatable<FixedString128Bytes>, IComparable<FixedString512Bytes>, IEquatable<FixedString512Bytes>, IComparable<FixedString4096Bytes>, IEquatable<FixedString4096Bytes>

    Properties

    Capacity

    The current capacity in bytes of this string.

    Declaration
    public int Capacity { get; set; }
    Property Value
    Type Description
    Int32

    The current capacity in bytes of the string.

    Implements
    INativeList<T>.Capacity
    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 { get; set; }
    Property Value
    Type Description
    Boolean

    True if this string has no characters or if the string has not been constructed.

    Implements
    INativeList<T>.IsEmpty
    IUTF8Bytes.IsEmpty

    Item[Int32]

    The byte at an index.

    Declaration
    public byte this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index

    A zero-based byte index.

    Property Value
    Type Description
    Byte

    The byte at the index.

    Implements
    INativeList<T>.Item[Int32]
    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 { get; set; }
    Property Value
    Type Description
    Int32

    The current length in bytes of the UTF-8 encoded string.

    Implements
    IIndexable<T>.Length
    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.

    Value

    A copy of this string as a managed string.

    Declaration
    public readonly string Value { get; }
    Property Value
    Type Description
    String

    A copy of this string as a managed string.

    Remarks

    For internal use only. Use ToString() instead.

    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()
    Implements
    INativeList<T>.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
    public int CompareTo(string other)
    Parameters
    Type Name Description
    String other

    Another string to compare with.

    Returns
    Type Description
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    CompareTo(NativeText.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
    Int32

    A number denoting the lexicographical sort order of this string relative to the other string:

    0 denotes both strings have the same sort position.
    -1 denotes that this string should be sorted to precede the other.
    +1 denotes that this string should be sorted to follow the other.

    ElementAt(Int32)

    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
    Int32 index

    A byte index.

    Returns
    Type Description
    Byte

    A reference to the byte at the index.

    Implements
    IIndexable<T>.ElementAt(Int32)
    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
    public override bool Equals(object other)
    Parameters
    Type Name Description
    Object other

    Another string to compare with.

    Returns
    Type Description
    Boolean

    True if this string and the object are equal.

    Overrides
    ValueType.Equals(Object)
    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
    public bool Equals(string other)
    Parameters
    Type Name Description
    String other

    Another string to compare with.

    Returns
    Type Description
    Boolean

    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
    Boolean

    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
    Boolean

    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
    Boolean

    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
    Boolean

    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
    Boolean

    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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Equals(NativeText.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
    Boolean

    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
    Int32

    A hash code of this string.

    Overrides
    ValueType.GetHashCode()
    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.

    Implements
    IUTF8Bytes.GetUnsafePtr()
    Remarks

    The pointer is made invalid by operations that reallocate the character buffer, such as setting .

    ToString()

    Returns a managed string copy of this string.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A managed string copy of this string.

    Overrides
    ValueType.ToString()

    TryResize(Int32, 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
    Int32 newLength

    The new length in bytes of the string.

    NativeArrayOptions clearOptions

    Whether any bytes added should be zeroed out.

    Returns
    Type Description
    Boolean

    Always false.

    Implements
    IUTF8Bytes.TryResize(Int32, NativeArrayOptions)
    Exceptions
    Type Condition
    NotSupportedException

    Thrown if ENABLE_UNITY_COLLECTIONS_CHECKS is defined.

    Operators

    Equality(in NativeText.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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Equality(in NativeText.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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Equality(in NativeText.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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Equality(in NativeText.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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Equality(in NativeText.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
    Boolean

    True if the two strings are equal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Inequality(in NativeText.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
    Boolean

    True if the two strings are unequal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Inequality(in NativeText.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
    Boolean

    True if the two strings are unequal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Inequality(in NativeText.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
    Boolean

    True if the two strings are unequal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Inequality(in NativeText.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
    Boolean

    True if the two strings are unequal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Inequality(in NativeText.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
    Boolean

    True if the two strings are unequal.

    Remarks

    Two strings are equal if they have equal length and all their characters match.

    Extension Methods

    FixedStringMethods.Append<T>(ref T, Unicode.Rune)
    FixedStringMethods.Append<T>(ref T, Char)
    FixedStringMethods.AppendRawByte<T>(ref T, Byte)
    FixedStringMethods.Append<T>(ref T, Unicode.Rune, Int32)
    FixedStringMethods.Append<T>(ref T, Int64)
    FixedStringMethods.Append<T>(ref T, Int32)
    FixedStringMethods.Append<T>(ref T, UInt64)
    FixedStringMethods.Append<T>(ref T, UInt32)
    FixedStringMethods.Append<T>(ref T, Single, Char)
    FixedStringMethods.Append<T, T2>(ref T, in T2)
    FixedStringMethods.CopyFrom<T, T2>(ref T, in T2)
    FixedStringMethods.Append<T>(ref T, Byte*, Int32)
    FixedStringMethods.Append<T>(ref T, String)
    FixedStringMethods.CopyFrom<T>(ref T, String)
    FixedStringMethods.CopyFromTruncated<T>(ref T, String)
    FixedStringMethods.AppendFormat<T, U, T0>(ref T, in U, in T0)
    FixedStringMethods.AppendFormat<T, U, T0, T1>(ref T, in U, in T0, in T1)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2>(ref T, in U, in T0, in T1, in T2)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3>(ref T, in U, in T0, in T1, in T2, in T3)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4>(ref T, in U, in T0, in T1, in T2, in T3, in T4)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5>(ref T, in U, in T0, in T1, in T2, in T3, in T4, in T5)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6>(ref T, in U, in T0, in T1, in T2, in T3, in T4, in T5, in T6)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7>(ref T, in U, in T0, in T1, in T2, in T3, in T4, in T5, in T6, in T7)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8>(ref T, in U, in T0, in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8)
    FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref T, in U, in T0, in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9)
    FixedStringMethods.IndexOf<T>(ref T, Byte*, Int32)
    FixedStringMethods.IndexOf<T>(ref T, Byte*, Int32, Int32, Int32)
    FixedStringMethods.IndexOf<T, T2>(ref T, in T2)
    FixedStringMethods.IndexOf<T, T2>(ref T, in T2, Int32, Int32)
    FixedStringMethods.Contains<T, T2>(ref T, in T2)
    FixedStringMethods.LastIndexOf<T>(ref T, Byte*, Int32)
    FixedStringMethods.LastIndexOf<T>(ref T, Byte*, Int32, Int32, Int32)
    FixedStringMethods.LastIndexOf<T, T2>(ref T, in T2)
    FixedStringMethods.LastIndexOf<T, T2>(ref T, in T2, Int32, Int32)
    FixedStringMethods.CompareTo<T>(ref T, Byte*, Int32)
    FixedStringMethods.CompareTo<T, T2>(ref T, in T2)
    FixedStringMethods.Equals<T>(ref T, Byte*, Int32)
    FixedStringMethods.Equals<T, T2>(ref T, in T2)
    FixedStringMethods.Peek<T>(ref T, Int32)
    FixedStringMethods.Read<T>(ref T, ref Int32)
    FixedStringMethods.Write<T>(ref T, ref Int32, Unicode.Rune)
    FixedStringMethods.ConvertToString<T>(ref T)
    FixedStringMethods.ComputeHashCode<T>(ref T)
    FixedStringMethods.EffectiveSizeOf<T>(ref T)
    FixedStringMethods.Parse<T>(ref T, ref Int32, ref Int32)
    FixedStringMethods.Parse<T>(ref T, ref Int32, ref UInt32)
    FixedStringMethods.Parse<T>(ref T, ref Int32, ref Single, Char)
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Tuesday, June 14, 2022
    Terms of use