Blob length fix
This commit is contained in:
@@ -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
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class ByteArrayPropertyWithLength<T>(
|
||||
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!!
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package nl.astraeus.tba
|
||||
|
||||
import kotlin.math.min
|
||||
|
||||
class SlicedByteArray(
|
||||
val data: ByteArray,
|
||||
val offset: Int,
|
||||
|
||||
@@ -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<String, Type>()
|
||||
val indexMap = mutableMapOf<String, Int>()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user