TypedByteArray

open class TypedByteArray(types: Type)

A class that provides a typed interface to a byte array.

TypedByteArray allows you to define a structured byte array with named fields of specific types and sizes. It serves as a base class for creating custom byte array structures with convenient property access.

Example usage:

class PersonData : TypedByteArray(
Type("name", DataType.STRING, 50),
Type("age", DataType.BYTE),
Type("height", DataType.SHORT)
) {
var name by string("name")
var age by byte("age")
var height by short("height")
}

Parameters

types

The types that define the structure of the byte array. Each type has a name, a data type, and optionally a size.

Constructors

Link copied to clipboard
constructor(vararg types: Type)

Properties

Link copied to clipboard

The handler for the underlying byte array data. This can be replaced to point to a different byte array.

Link copied to clipboard

Maps type names to their starting indices in the byte array.

Link copied to clipboard

Maps type names to their Type objects.

Functions

Link copied to clipboard
Link copied to clipboard
fun updateTypes(vararg types: Type)

Updates the internal structures with the provided types. This method reinitializes the necessary definitions, data handlers, and mapping structures based on the input types.