docs.unity3d.com
    目次を表示する/隠す

    Struct UnsafeText

    An unmanaged, mutable, resizable UTF-8 string.

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

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

    Constructors

    UnsafeText(Int32, AllocatorManager.AllocatorHandle)

    Initializes and returns an instance of UnsafeText.

    Declaration
    public UnsafeText(int capacity, AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    Int32 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 { 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.

    IsCreated

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

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

    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
    Boolean

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

    Implements
    IUTF8Bytes.IsEmpty
    INativeList<T>.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.

    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.

    Methods

    Clear()

    Sets the length to 0.

    Declaration
    public void Clear()
    Implements
    INativeList<T>.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.

    Implements
    INativeDisposable.Dispose(JobHandle)

    ElementAt(Int32)

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

    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

    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.

    Implements
    IUTF8Bytes.GetUnsafePtr()
    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(Int32, 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
    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 true.

    Implements
    IUTF8Bytes.TryResize(Int32, NativeArrayOptions)

    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.CopyFromTruncated<T, T2>(ref T, in T2)
    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, Unicode.Rune)
    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, Unicode.Rune)
    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)
    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)