final class · System
ResourceData
public final class ResourceData
Read-only bytes of a resource, read in place from the program's static data (no copy): indexed, iterated, sliced.
- Kind
- final class
- Namespace
- System
- Assembly
- System.Core
- Access
- public, final
- Source file
Resources.ant
Inheritance
- Base classes
-
AnyResourceData
Properties
Methods
The byte at index (data[index]).
A copy of the bytes.
Text() : str
#
The bytes as UTF-8 text.
Iterator() : ResourceIterator
#
The bytes in order (loop (u8 b in data)).
Slice(i32 start, i32 count) : ResourceData
#
count bytes from start, in place (no copy).
Slice(i32 start) : ResourceData
#
The bytes from start on, in place.
Whether these are the same bytes as bytes (one comparison in memory).
Operators and conversions
op ==(ResourceData a, u8[] b) : bool
#
op !=(ResourceData a, u8[] b) : bool
#
op ==(u8[] a, ResourceData b) : bool
#
op !=(u8[] a, ResourceData b) : bool
#
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
ResourceData as Antril, decompiled from its Larva HIR.
// System.ResourceData — System.Core (decompiled from Larva HIR)
import System.Runtime.InteropServices;
into namespace System
{
/// Read-only bytes of a resource, read in place from the program's static data (no copy): indexed, iterated, sliced.
public final class ResourceData
{
u8* data;
i32 length;
internal:
new(u8* data, i32 length)
{
this.data = data;
this.length = length;
}
public:
/// The byte at `index` (`data[index]`).
At(i32 index) : u8
{
if ((u32)index >= (u32)length)
Fail.Index();
unsafe
{
return *(data + (i64)index);
}
}
/// A copy of the bytes.
ToArray() : u8[]
{
u8[] copy = new u8[length];
if (length > 0)
{
unsafe
{
Memory.Copy(©[0], data, length);
}
}
return copy;
}
/// The bytes as UTF-8 text.
Text() : str => new str(ToArray());
/// The bytes in order (`loop (u8 b in data)`).
Iterator() : ResourceIterator => new ResourceIterator(data, length);
/// `count` bytes from `start`, in place (no copy).
Slice(i32 start, i32 count) : ResourceData
{
if ((u32)start > (u32)length || (u32)count > (u32)(length - start))
Fail.Index();
unsafe
{
return new ResourceData(data + (i64)start, count);
}
}
/// The bytes from `start` on, in place.
Slice(i32 start) : ResourceData => Slice(start, length - start);
/// Whether these are the same bytes as `bytes` (one comparison in memory).
Equals(u8[] bytes) : bool
{
if (bytes.Length != length)
return false;
if (length == 0)
return true;
unsafe
{
return Memory.Compare(data, &bytes[0], length) == 0;
}
}
op ==(ResourceData a, u8[] b) : bool => a.Equals(b);
op !=(ResourceData a, u8[] b) : bool => !a.Equals(b);
op ==(u8[] a, ResourceData b) : bool => b.Equals(a);
op !=(u8[] a, ResourceData b) : bool => !b.Equals(a);
/// How many bytes.
i32 Length
{
get => length;
}
}
}