NativeText
An unmanaged, mutable, resizable UTF-8 string.
Read time 4 minutesLast updated 7 days ago
Definition
- Type: Struct
- Namespace: Unity.Collections
- Assembly: UnityEngine.ManagedKernelModule
- Implements: INativeList<byte>, IIndexable<byte>, INativeDisposable, IDisposable, 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>
public struct NativeText : INativeList<byte>, IIndexable<byte>, INativeDisposable, IDisposable, 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>
Remarks
The string is always null-terminated, meaning a zero byte always immediately follows the last character.
Static Fields
Value | Description |
|---|---|
| MaxCapacity | The maximum number of elements this type of container can hold. |
Constructors
Constructor | Description |
|---|---|
| NativeText(System.Int32,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText. |
| NativeText(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(System.String,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(System.String,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with an initial capacity of 512 bytes. |
| NativeText(Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString128Bytes@,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString128Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString32Bytes@,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString32Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString4096Bytes@,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString4096Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString512Bytes@,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString512Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString64Bytes@,Unity.Collections.Allocator) | Initializes and returns an instance of NativeText with the characters copied from another string. |
| NativeText(Unity.Collections.FixedString64Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of NativeText with the characters copied from another string. |
Properties
Property | Description |
|---|---|
| Capacity | The current capacity in bytes of this string. |
| IsCreated | Whether this string's character buffer has been allocated (and not yet deallocated). |
| IsEmpty | Whether this string has no characters. |
| this[] | The byte at an index. Note that writing to a NativeText.Readonly is not supported; the setter of this property throws when safety checks are enabled. |
| Length | The current length in bytes of this string. |
| Value | A copy of this string as a managed string. |
Methods
Method | Description |
|---|---|
| Add | Appends a byte. |
| AsReadOnly | Returns a readonly version of this NativeText instance. |
| Clear | Sets the length to 0. |
| CompareTo | Returns the lexicographical sort order of this string relative to another. |
| Dispose | Releases all resources (memory and safety handles). |
| ElementAt | Returns a reference to the byte (not character) at an index. |
| Equals | Returns true if this string and another object are equal. |
| GetEnumerator | Returns an enumerator for iterating over the characters of the NativeText. |
| GetHashCode | Returns a hash code of this string. |
| GetUnsafePtr | Returns a pointer to this string's character buffer. |
| ToString | Returns a managed string copy of this string. |
| TryResize | Attempt to set the length in bytes of this string. |
Operators
Operator | Description |
|---|---|
| operator == | Returns true if two strings are equal. |
| operator != | Returns true if two strings are unequal. |
Structs
Struct | Description |
|---|---|
| NativeText.Enumerator | An enumerator over the characters (not bytes) of a NativeText. |
| NativeText.ReadOnly | A read-only alias for the value of a NativeText. Does not have its own allocated storage. |