Buffer
Buffer
object Buffer
Read and write data to a string Buffer
init
static fun init(int capacity = 0) > Buffer
Create a Buffer
capacity: Optional initial capacity of theBuffer
Returns: New Buffer
fromStr
static fun fromStr(str string) > Buffer
Create a Buffer with string as its initial value
string: Initial value
Returns: New Buffer
collect
fun collect() > void
Free underlying memory (automatically called by the Garbage Collector)
read
fun read(int n = 1) > str?
Read bytes
n: How many bytes to read
Returns: Binary string
write
fun write(str bytes) > void !> WriteWhileReadingError
Write bytes
bytes: Bytes to write
writeZ
fun writeZ::<T>(str zigType, [T] values) > void !> WriteWhileReadingError, FFITypeMismatchError
Write values to the Buffer checking that T matches the zig type specified by zigType
zigType: Zig type (must match C ABI)values: Values to write
writeZAt
fun writeZAt::<T>(int at, str zigType, [T] values) > void !> WriteWhileReadingError, FFITypeMismatchError
Write values to the Buffer at index at, checking that T matches the zig type specified by zigType
at: Where to write the data in theBufferzigType: Zig type (must match C ABI)values: Values to write
readZ
fun readZ::<T>(str zigType) > T !> FFITypeMismatchError
Read data from the Buffer checking that T matches the zig type specified by zigType
zigType: Zig type (must match C ABI)
Returns: Data read of buzz type T and zig type zigType
readZAt
fun readZAt::<T>(int at, str zigType) > T !> FFITypeMismatchError
Read data from the Buffer at index at, checking that T matches the zig type specified by zigType
at: Where to read the data in theBufferzigType: Zig type (must match C ABI)
Returns: Data read of buzz type T and zig type zigType
writeStruct
fun writeStruct::<T>(type structType, [T] values) > void !> WriteWhileReadingError, FFITypeMismatchError
Write foreign struct(s) of type T to the Buffer. The struct type is specified both for the compiler with generic type T and to the function with structType which will be used to know the specific layout and size of the struct.
structType: Struct typevalues: Values to write
writeStructAt
fun writeStructAt::<T>(type structType, int at, [T] values) > void !> WriteWhileReadingError, FFITypeMismatchError
Write foreign struct(s) of type T to the Buffer at index at. The struct type is specified both for the compiler with generic type T and to the function with structType which will be used to know the specific layout and size of the struct.
structType: Struct typeat: Where to write the data to theBuffervalues: Values to write
readStruct
fun readStruct::<T>(type structType) > T !> FFITypeMismatchError
Read foreign struct of type T from the Buffer. The struct type is specified both for the compiler with generic type T and to the function with structType which will be used to know the specific layout and size of the struct.
structType: Struct type
Returns: Value read
readStructAt
fun readStructAt::<T>(type structType, int at) > T !> FFITypeMismatchError
Read foreign struct of type T from the Buffer at index at. The struct type is specified both for the compiler with generic type T and to the function with structType which will be used to know the specific layout and size of the struct.
structType: Struct type
Returns: Value read
readBoolean
fun readBoolean() > bool?
Read a boolean
Returns: Boolean read
writeBoolean
fun writeBoolean(bool boolean) > void !> WriteWhileReadingError
Write a boolean
boolean: Boolean to write
readInt
fun readInt() > int?
Read a integer
Returns: Integer read
writeInt
fun writeInt(int number) > void !> WriteWhileReadingError
Write an integer
number: Integer to write
readUserData
fun readUserData() > ud?
Read a ud
Returns: ud read
writeUserData
fun writeUserData(ud userdata) > void !> WriteWhileReadingError
Write an ud
userdata: ud to write
readDouble
fun readDouble() > double?
Read a double
Returns: Double read
writeDouble
fun writeDouble(double number) > void !> WriteWhileReadingError
Write an double
number: Double to write
len
fun len(int align = 1) > int
Get Buffer length
align: Alignement
Returns: Buffer length
cursor
fun cursor() > int
Get current position in the Buffer
Returns: Current position
empty
fun empty() > void
Empty the Buffer (retains capacity)
ptr
fun ptr(int at = 0, int align = 1) > ud
Returns pointer at at * align in the Buffer as userdata
at: From where to get the pointeralign: Alignment
Returns: Pointer
toString
fun toString() > str
Get Buffer content as a string
Returns: Buffer content
at
fun at(int index) > int !> OutOfBoundError
Get byte at given index
index: Which byte to get
Returns: Byte
setAt
fun setAt(int index, int value) > void !> WriteWhileReadingError, OutOfBoundError
Set byte at given index
index: Which byte to setvalue: Value to set
