Struct FixedString32
An unmanaged string in UTF-8 format that contains its own fixed-size buffer of the given size in bytes.
The string is NOT guaranteed to be null-terminated, though in many cases it may be by accident.
No memory is ever allocated, and no attempt is made to share memory when strings are copied.
Since this structure is not generic and needs no disposing, it can exist inside ECS components,
can be put in a FixedArray, FixedList or FixedHashMap, and can be a data member of unmanaged structs
that are allocated from the unmanaged heap. This string is entirely compatible with Burst compilation.
The binary layout of this string is guaranteed, for now and all time, to be two bytes of little-endian length,
followed by a contiguous array of bytes with that length, with no padding in between. This is intentionally
identical to FixedList of byte, which is guaranteed to always have the same memory layout.
Those who need more than 65,535 contiguous items should allocate from the heap, as storing that many things
contiguously in a C# struct is likely to result in much wasted time, as the compiler copies the struct often.
Syntax
public struct FixedString32 : INativeList<byte>, IUTF8Bytes, IComparable<string>, IEquatable<string>, IComparable<FixedString32>, IEquatable<FixedString32>, IComparable<FixedString64>, IEquatable<FixedString64>, IComparable<FixedString128>, IEquatable<FixedString128>, IComparable<FixedString512>, IEquatable<FixedString512>, IComparable<FixedString4096>, IEquatable<FixedString4096>
Constructors
FixedString32(String)
Construct a FixedString32 from a System.String object.
Declaration
public FixedString32(string source)
Parameters
Type |
Name |
Description |
String |
source |
The System.String object to construct this FixedString32 with
|
FixedString32(FixedString128)
Construct a FixedString32 by copying from another FixedString source.
Declaration
public FixedString32(in FixedString128 source)
Parameters
FixedString32(FixedString32)
Construct a FixedString32 by copying from another FixedString source.
Declaration
public FixedString32(in FixedString32 source)
Parameters
FixedString32(FixedString4096)
Construct a FixedString32 by copying from another FixedString source.
Declaration
public FixedString32(in FixedString4096 source)
Parameters
FixedString32(FixedString512)
Construct a FixedString32 by copying from another FixedString source.
Declaration
public FixedString32(in FixedString512 source)
Parameters
FixedString32(FixedString64)
Construct a FixedString32 by copying from another FixedString source.
Declaration
public FixedString32(in FixedString64 source)
Parameters
Properties
Capacity
The maximum length of the UTF-8 encopded string, in bytes.
Due to the UTF-8 encoding, each Unicode code point requires between 1 and 4 bytes to encode.
The null terminating byte is not included in the capacity. The FixedString always
has space for a null terminating byte.
Declaration
public int Capacity { get; set; }
Property Value
Implements
IsEmpty
Reports whether container is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type |
Description |
Boolean |
True if this container empty.
|
Implements
Item[Int32]
Return the byte at the given byte (not character) index. The index
must be in the range of [0..Length)
Declaration
public byte this[int index] { get; set; }
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Property Value
Implements
Length
The current length of the UTF-8 encoded string, in bytes.
The string is guaranteed to he null-terminated. The length value
does not include the null terminating byte.
Declaration
public int Length { get; set; }
Property Value
Implements
UTF8MaxLengthInBytes
Returns the maximum number of utf8 bytes that can be stored in this type.
Declaration
public static int UTF8MaxLengthInBytes { get; }
Property Value
Value
A property in order to display the value in Unity.Properties generated UI.
Declaration
public string Value { get; }
Property Value
Methods
Add(Byte)
Declaration
public void Add(in byte value)
Parameters
Type |
Name |
Description |
Byte |
value |
|
AsFixedList()
Transform this struct to a reference to a FixedListByteN, which has the same layout.
The returned reference is a reference to this data, and is only valid while it is valid.
Declaration
public FixedListByte32 AsFixedList()
Returns
Clear()
Declaration
Implements
CompareTo(String)
Compare this FixedString32 with a System.String in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(string other)
Parameters
Type |
Name |
Description |
String |
other |
The System.String to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other System.String would appear first if sorted.
|
CompareTo(FixedString128)
Compare this FixedString32 with a FixedString128 in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(FixedString128 other)
Parameters
Type |
Name |
Description |
FixedString128 |
other |
The FixedString to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other FixedString128 would appear first if sorted.
|
CompareTo(FixedString32)
Compare this FixedString32 with a FixedString32 in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(FixedString32 other)
Parameters
Type |
Name |
Description |
FixedString32 |
other |
The FixedString to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other FixedString32 would appear first if sorted.
|
CompareTo(FixedString4096)
Compare this FixedString32 with a FixedString4096 in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(FixedString4096 other)
Parameters
Type |
Name |
Description |
FixedString4096 |
other |
The FixedString to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other FixedString4096 would appear first if sorted.
|
CompareTo(FixedString512)
Compare this FixedString32 with a FixedString512 in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(FixedString512 other)
Parameters
Type |
Name |
Description |
FixedString512 |
other |
The FixedString to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other FixedString512 would appear first if sorted.
|
CompareTo(FixedString64)
Compare this FixedString32 with a FixedString64 in terms of lexigraphical order,
and return which of the two strings would come first if sorted.
Declaration
public int CompareTo(FixedString64 other)
Parameters
Type |
Name |
Description |
FixedString64 |
other |
The FixedString to compare with
|
Returns
Type |
Description |
Int32 |
-1 if this FixedString32 would appear first if sorted,
0 if they are identical, or
1 if the other FixedString64 would appear first if sorted.
|
ElementAt(Int32)
Return a ref to the the byte at the given byte (not character) index. The index
must be in the range of [0..Length). The ref byte is a direct reference into
this FixedString, and is only valid while this FixedString is valid.
Declaration
public byte ElementAt(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
Implements
Equals(Object)
Determines whether a FixedString32 has the same value as some other object.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
The object to compare for equality
|
Returns
Overrides
Equals(String)
Compare this FixedString32 with a System.String,
and return whether they contain the same string or not.
Declaration
public bool Equals(string other)
Parameters
Type |
Name |
Description |
String |
other |
The System.String to compare with
|
Returns
Type |
Description |
Boolean |
true if they are equal, or false if they are not.
|
Equals(FixedString128)
Declaration
public bool Equals(FixedString128 other)
Parameters
Returns
Equals(FixedString32)
Declaration
public bool Equals(FixedString32 other)
Parameters
Returns
Equals(FixedString4096)
Declaration
public bool Equals(FixedString4096 other)
Parameters
Returns
Equals(FixedString512)
Declaration
public bool Equals(FixedString512 other)
Parameters
Returns
Equals(FixedString64)
Declaration
public bool Equals(FixedString64 other)
Parameters
Returns
GetEnumerator()
Returns an enumerator that iterates through a container.
Declaration
public FixedString32.Enumerator GetEnumerator()
Returns
GetHashCode()
Compute a hash code of this FixedString32: an integer that is likely to be different for
two FixedString32, if their contents are different.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
Int32 |
A hash code of this FixedString32
|
Overrides
GetUnsafePtr()
Declaration
public byte *GetUnsafePtr()
Returns
Implements
ToString()
Convert this FixedString32 to a System.String.
Declaration
public override string ToString()
Returns
Type |
Description |
String |
A System.String with a copy of this FixedString32
|
Overrides
Operators
Equality(FixedString32, FixedString128)
Declaration
public static bool operator ==(in FixedString32 a, in FixedString128 b)
Parameters
Returns
Equality(FixedString32, FixedString32)
Declaration
public static bool operator ==(in FixedString32 a, in FixedString32 b)
Parameters
Returns
Equality(FixedString32, FixedString4096)
Declaration
public static bool operator ==(in FixedString32 a, in FixedString4096 b)
Parameters
Returns
Equality(FixedString32, FixedString512)
Declaration
public static bool operator ==(in FixedString32 a, in FixedString512 b)
Parameters
Returns
Equality(FixedString32, FixedString64)
Declaration
public static bool operator ==(in FixedString32 a, in FixedString64 b)
Parameters
Returns
Implicit(String to FixedString32)
Enable implicit conversion of System.String to FixedString32.
Declaration
public static implicit operator FixedString32(string b)
Parameters
Type |
Name |
Description |
String |
b |
The System.String object to convert to a FixedString32
|
Returns
Implicit(FixedString32 to FixedString128)
Declaration
public static implicit operator FixedString128(in FixedString32 fs)
Parameters
Returns
Implicit(FixedString32 to FixedString4096)
Declaration
public static implicit operator FixedString4096(in FixedString32 fs)
Parameters
Returns
Implicit(FixedString32 to FixedString512)
Declaration
public static implicit operator FixedString512(in FixedString32 fs)
Parameters
Returns
Implicit(FixedString32 to FixedString64)
Declaration
public static implicit operator FixedString64(in FixedString32 fs)
Parameters
Returns
Inequality(FixedString32, FixedString128)
Declaration
public static bool operator !=(in FixedString32 a, in FixedString128 b)
Parameters
Returns
Inequality(FixedString32, FixedString32)
Declaration
public static bool operator !=(in FixedString32 a, in FixedString32 b)
Parameters
Returns
Inequality(FixedString32, FixedString4096)
Declaration
public static bool operator !=(in FixedString32 a, in FixedString4096 b)
Parameters
Returns
Inequality(FixedString32, FixedString512)
Declaration
public static bool operator !=(in FixedString32 a, in FixedString512 b)
Parameters
Returns
Inequality(FixedString32, FixedString64)
Declaration
public static bool operator !=(in FixedString32 a, in FixedString64 b)
Parameters
Returns
Extension Methods
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3>(ref T, U, T0, T1, T2, T3)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4>(ref T, U, T0, T1, T2, T3, T4)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5>(ref T, U, T0, T1, T2, T3, T4, T5)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6>(ref T, U, T0, T1, T2, T3, T4, T5, T6)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7>(ref T, U, T0, T1, T2, T3, T4, T5, T6, T7)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8>(ref T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8)
FixedStringMethods.AppendFormat<T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref T, U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)