ReadBuffer

interface ReadBuffer

Represent a chunk of data, where FlexBuffers will be read from.

Inheritors

Properties

Link copied to clipboard
abstract val limit: Int

Defines the size of the message in the buffer. It also determines last position that buffer can be read. Last byte to be accessed is in position limit() -1.

Functions

Link copied to clipboard
abstract fun data(): ByteArray

Expose ReadBuffer as an array of bytes. This method is meant to be as efficient as possible, so for an array-backed ReadBuffer, it should return its own internal data. In case access to internal data is not possible, a copy of the data into an array of bytes might occur.

Link copied to clipboard
abstract fun findFirst(value: Byte, start: Int, end: Int = limit): Int

Scan through the buffer for first byte matching value.

Link copied to clipboard
abstract operator fun get(index: Int): Byte

Read a Byte from the buffer.

Link copied to clipboard
abstract fun getBoolean(index: Int): Boolean

Read boolean from the buffer. Booleans as stored as a single byte

Link copied to clipboard
abstract fun getBytes(array: ByteArray, start: Int, length: Int = array.size)

Read a ByteArray from the buffer.

Link copied to clipboard
abstract fun getDouble(index: Int): Double

Read a 64-bit float from the buffer.

Link copied to clipboard
abstract fun getFloat(index: Int): Float

Read a 32-bit float from the buffer.

Link copied to clipboard
abstract fun getInt(index: Int): Int

Read a Int from the buffer.

Link copied to clipboard
abstract fun getLong(index: Int): Long

Read a Long from the buffer.

Link copied to clipboard
abstract fun getShort(index: Int): Short

Read a Short from the buffer.

Link copied to clipboard
abstract fun getString(start: Int = 0, size: Int = limit): String

Read a UTF-8 string from the buffer.

Link copied to clipboard
abstract fun getUByte(index: Int): UByte

Read a UByte from the buffer.

Link copied to clipboard
abstract fun getUInt(index: Int): UInt

Read a UInt from the buffer.

Link copied to clipboard
abstract fun getULong(index: Int): ULong

Read a ULong from the buffer.

Link copied to clipboard
abstract fun getUShort(index: Int): UShort

Read a UShort from the buffer.

Link copied to clipboard
abstract fun slice(start: Int, size: Int): ReadBuffer

Creates a new ReadBuffer point to a region of the current buffer, starting at start with size size.