initial: varing and smarting packing tools
This commit is contained in:
commit
0f9702b1dc
15 files changed
+914
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package net.sergeych.bintools
|
||||
|
||||
abstract class DataSink {
|
||||
|
||||
abstract fun writeByte(data: Byte)
|
||||
|
||||
fun writeByte(data: Int) = writeByte(data.toByte())
|
||||
|
||||
open fun writeUByte(data: UByte) {
|
||||
writeByte(data.toByte())
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
open fun writeBytes(data: ByteArray) {
|
||||
for(d in data) writeByte(d)
|
||||
}
|
||||
}
|
||||
|
||||
class ArrayDataSink : DataSink() {
|
||||
private val result = mutableListOf<Byte>()
|
||||
|
||||
override fun writeByte(data: Byte) {
|
||||
result.add(data)
|
||||
}
|
||||
|
||||
fun toByteArray() = result.toByteArray()
|
||||
}
|
||||
Reference in new issue
Block a user