diff --git a/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayDefinition.kt b/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayDefinition.kt index 49fe027..d3535b5 100644 --- a/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayDefinition.kt +++ b/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayDefinition.kt @@ -10,10 +10,9 @@ enum class DataType( LONG(8), FLOAT(4), DOUBLE(8), - STRING(-1, 2), // max length 65535 - CLOB(-1, 4), // max length 2^32-1 + STRING(-1, 2), + CLOB(-1, 4), BLOB(-1, 4), - //SLICE(-1, 4) // max length 2^32-1 ; } diff --git a/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayProperties.kt b/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayProperties.kt index f9d4561..01c0ec1 100644 --- a/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayProperties.kt +++ b/src/commonMain/kotlin/nl/astraeus/tba/ByteArrayProperties.kt @@ -26,7 +26,7 @@ abstract class ByteArrayPropertyWithLength( val type = thisRef.typeMap[name] ?: throw IllegalArgumentException( "Type $name not found in typemap in $thisRef" ) - maxLength = type.size + maxLength = type.size - type.type.bytesUsedInternally } return maxLength!! } diff --git a/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt b/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt index 1b62bae..6b07949 100644 --- a/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt +++ b/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt @@ -1,7 +1,5 @@ package nl.astraeus.tba -import kotlin.math.min - class SlicedByteArray( val data: ByteArray, val offset: Int, diff --git a/src/commonMain/kotlin/nl/astraeus/tba/TypedByteArray.kt b/src/commonMain/kotlin/nl/astraeus/tba/TypedByteArray.kt index 99b5846..1e2c835 100644 --- a/src/commonMain/kotlin/nl/astraeus/tba/TypedByteArray.kt +++ b/src/commonMain/kotlin/nl/astraeus/tba/TypedByteArray.kt @@ -1,9 +1,11 @@ package nl.astraeus.tba open class TypedByteArray( - val definition: ByteArrayDefinition, - var data: MutableByteArrayHandler = MutableByteArrayHandler(SlicedByteArray(definition.size)), + vararg types: Type ) { + val definition: ByteArrayDefinition = ByteArrayDefinition(*types) + var data: MutableByteArrayHandler = MutableByteArrayHandler(SlicedByteArray(definition.size)) + val typeMap = mutableMapOf() val indexMap = mutableMapOf() @@ -18,11 +20,4 @@ open class TypedByteArray( index += type.size } } - - constructor(vararg types: Type): this(ByteArrayDefinition(*types)) - - constructor(data: ByteArray): this(ByteArrayDefinition()) { - check(data.size == definition.size) { "Data size ${data.size} does not match definition size ${definition.size}" } - this.data = MutableByteArrayHandler(buffer = data) - } }