docs.unity3d.com

Collections 2.4.1

Search Results for

    Show / Hide Table of Contents

    Struct UnsafeText

    An unmanaged, mutable, resizable UTF-8 string.

    Implements
    INativeDisposable
    IUTF8Bytes
    INativeList<byte>
    IIndexable<byte>
    Namespace: Unity.Collections.LowLevel.Unsafe
    Assembly: Unity.Collections.dll
    Syntax
    public struct UnsafeText : INativeDisposable, IUTF8Bytes, INativeList<byte>, IIndexable<byte>
    Remarks

    The string is always null-terminated, meaning a zero byte always immediately follows the last character.

    Constructors

    UnsafeText(int, AllocatorHandle)

    Initializes and returns an instance of UnsafeText.

    Declaration
    public UnsafeText(int capacity, AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    int capacity

    The initial capacity, in bytes.

    AllocatorManager.AllocatorHandle allocator

    The allocator to use.

    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.

    IsCreated

    Whether this string's character buffer has been allocated (and not yet deallocated).

    Declaration
    public readonly bool IsCreated { get; }
    Property Value
    Type Description
    bool

    Whether this string's character buffer has been allocated (and not yet deallocated).

    IsEmpty

    Reports whether container is empty.

    Declaration
    public readonly bool IsEmpty { get; }
    Property Value
    Type Description
    bool

    True if the string is empty or the string has not been constructed.

    this[int]

    The byte at an index.

    Declaration
    public byte this[int index] { 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.

    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.

    Methods

    Clear()

    Sets the length to 0.

    Declaration
    public void Clear()

    Dispose()

    Releases all resources (memory).

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Creates and schedules a job that will dispose this string.

    Declaration
    public JobHandle Dispose(JobHandle inputDeps)
    Parameters
    Type Name Description
    JobHandle inputDeps

    The handle of a job which the new job will depend upon.

    Returns
    Type Description
    JobHandle

    The handle of a new job that will dispose this string. The new job depends upon inputDeps.

    ElementAt(int)

    Returns a reference to the byte (not character) at an index.

    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

    Deallocating or reallocating this string's character buffer makes the reference invalid.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    Thrown if the index is out of bounds.

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

    TryResize(int, NativeArrayOptions)

    Attempt to set the length in bytes of this string.

    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 true.

    Implements

    INativeDisposable
    IUTF8Bytes
    INativeList<T>
    IIndexable<T>

    Extension Methods

    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.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.AppendRawByte<T>(ref T, byte)
    FixedStringMethods.Append<T>(ref T, byte*, int)
    FixedStringMethods.Append<T>(ref T, char)
    FixedStringMethods.Append<T>(ref T, int)
    FixedStringMethods.Append<T>(ref T, long)
    FixedStringMethods.Append<T>(ref T, float, char)
    FixedStringMethods.Append<T>(ref T, string)
    FixedStringMethods.Append<T>(ref T, uint)
    FixedStringMethods.Append<T>(ref T, ulong)
    FixedStringMethods.Append<T>(ref T, Unicode.Rune)
    FixedStringMethods.Append<T>(ref T, Unicode.Rune, int)
    FixedStringMethods.Append<T, T2>(ref T, in T2)
    FixedStringMethods.CompareTo<T>(ref T, byte*, int)
    FixedStringMethods.CompareTo<T, T2>(ref T, in T2)
    FixedStringMethods.ComputeHashCode<T>(ref T)
    FixedStringMethods.Contains<T, T2>(ref T, in T2)
    FixedStringMethods.ConvertToString<T>(ref T)
    FixedStringMethods.CopyFromTruncated<T>(ref T, string)
    FixedStringMethods.CopyFromTruncated<T, T2>(ref T, in T2)
    FixedStringMethods.CopyFrom<T>(ref T, string)
    FixedStringMethods.CopyFrom<T, T2>(ref T, in T2)
    FixedStringMethods.EffectiveSizeOf<T>(ref T)
    FixedStringMethods.EndsWith<T>(ref T, Unicode.Rune)
    FixedStringMethods.EndsWith<T, U>(ref T, in U)
    FixedStringMethods.Equals<T>(ref T, byte*, int)
    FixedStringMethods.Equals<T, T2>(ref T, in T2)
    FixedStringMethods.IndexOf<T>(ref T, byte*, int)
    FixedStringMethods.IndexOf<T>(ref T, byte*, int, int, int)
    FixedStringMethods.IndexOf<T>(ref T, Unicode.Rune)
    FixedStringMethods.IndexOf<T, T2>(ref T, in T2)
    FixedStringMethods.IndexOf<T, T2>(ref T, in T2, int, int)
    FixedStringMethods.LastIndexOf<T>(ref T, byte*, int)
    FixedStringMethods.LastIndexOf<T>(ref T, byte*, int, int, int)
    FixedStringMethods.LastIndexOf<T>(ref T, Unicode.Rune)
    FixedStringMethods.LastIndexOf<T, T2>(ref T, in T2)
    FixedStringMethods.LastIndexOf<T, T2>(ref T, in T2, int, int)
    FixedStringMethods.Parse<T>(ref T, ref int, ref int)
    FixedStringMethods.Parse<T>(ref T, ref int, ref float, char)
    FixedStringMethods.Parse<T>(ref T, ref int, ref uint)
    FixedStringMethods.Peek<T>(ref T, int)
    FixedStringMethods.Read<T>(ref T, ref int)
    FixedStringMethods.StartsWith<T>(ref T, Unicode.Rune)
    FixedStringMethods.StartsWith<T, U>(ref T, in U)
    FixedStringMethods.Substring<T>(ref T, int)
    FixedStringMethods.Substring<T>(ref T, int, int)
    FixedStringMethods.ToLowerAscii(ref UnsafeText, AllocatorManager.AllocatorHandle)
    FixedStringMethods.ToLowerAscii<T>(ref T)
    FixedStringMethods.ToUpperAscii(ref UnsafeText, AllocatorManager.AllocatorHandle)
    FixedStringMethods.ToUpperAscii<T>(ref T)
    FixedStringMethods.Trim(ref UnsafeText, AllocatorManager.AllocatorHandle)
    FixedStringMethods.Trim(ref UnsafeText, AllocatorManager.AllocatorHandle, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.TrimEnd(ref UnsafeText, AllocatorManager.AllocatorHandle)
    FixedStringMethods.TrimEnd(ref UnsafeText, AllocatorManager.AllocatorHandle, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.TrimEnd<T>(ref T)
    FixedStringMethods.TrimEnd<T>(ref T, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.TrimStart(ref UnsafeText, AllocatorManager.AllocatorHandle)
    FixedStringMethods.TrimStart(ref UnsafeText, AllocatorManager.AllocatorHandle, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.TrimStart<T>(ref T)
    FixedStringMethods.TrimStart<T>(ref T, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.Trim<T>(ref T)
    FixedStringMethods.Trim<T>(ref T, ReadOnlySpan<Unicode.Rune>)
    FixedStringMethods.Write<T>(ref T, ref int, Unicode.Rune)
    In This Article
    • Constructors
      • UnsafeText(int, AllocatorHandle)
    • Properties
      • Capacity
      • IsCreated
      • IsEmpty
      • this[int]
      • Length
    • Methods
      • Clear()
      • Dispose()
      • Dispose(JobHandle)
      • ElementAt(int)
      • GetUnsafePtr()
      • ToString()
      • TryResize(int, NativeArrayOptions)
    • Implements
    • Extension Methods
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)