FlatBufferBuilder
Class that helps you build a FlatBuffer. See the section "Use in Kotlin" in the main FlatBuffers documentation.
Constructors
Functions
Adds on offset, relative to where it will be written.
Add a Boolean to the buffer, properly aligned, and grows the buffer (if necessary).
Add a Byte to the buffer, properly aligned, and grows the buffer (if necessary).
Add a Double to the buffer, properly aligned, and grows the buffer (if necessary).
Add a Float to the buffer, properly aligned, and grows the buffer (if necessary).
Add an Int to the buffer, properly aligned, and grows the buffer (if necessary).
Add a long
to the buffer, properly aligned, and grows the buffer (if necessary).
Add a Short to the buffer, properly aligned, and grows the buffer (if necessary).
Add a UByte to the buffer, properly aligned, and grows the buffer (if necessary).
Add an Unit to the buffer, properly aligned, and grows the buffer (if necessary).
Add a ULong to the buffer, properly aligned, and grows the buffer (if necessary).
Add a UShort to the buffer, properly aligned, and grows the buffer (if necessary).
Add an offset
to a table at o
into its vtable, with value x
and default d
.
Add a Boolean to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Byte to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Double to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Float to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Int to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Long to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a Short to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a UByte to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a UInt to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a ULong to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Add a UShort to a table at o
into its vtable, with value x
and default d
. If force_defaults
is false
, compare x
against the default value d
. If x
contains the default value, it can be skipped.
Create a byte array in the buffer.
Encode the String s
in the buffer using UTF-8. If a String with this exact contents has already been serialized using this method, instead simply returns the offset of the existing String.
Create a vector of sorted by the key tables.
Create a string in the buffer from an already encoded UTF-8 string in a ByteBuffer.
Encode the CharSequence s
in the buffer using UTF-8.
Create a new array/vector and return a ByteBuffer to be filled later. Call endVector after this method to get an offset to the beginning of vector.
Create a vector of tables.
Get the ByteBuffer representing the FlatBuffer. Only call this after you've called finish()
. The actual data starts at the ByteBuffer's current position, not necessarily at 0
.
Finish off the creation of an array and all its elements. The array must be created with .startVector.
Finalize a buffer, pointing to the given root_table
, with the size prefixed.
In order to save space, fields that are set to their default value don't get serialized into the buffer. Forcing defaults provides a way to manually disable this optimization.
Helper function to test if a field is present in the table
Prepare to write an element of size
after additional_bytes
have been written, e.g. if you write a string, you need to align such the int length field is aligned to com.google.flatbuffers.Int.SIZE_BYTES, and the string data follows it directly. If all you need to do is alignment, additional_bytes
will be 0.
Add a boolean
to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a Byte to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a Double to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a Float to the buffer, backwards from the current location. Doesn't align nor check for space.
Add an Int to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a Long to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a Short to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a UByte to the buffer, backwards from the current location. Doesn't align nor check for space.
Add an UInt to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a ULong to the buffer, backwards from the current location. Doesn't align nor check for space.
Add a UShort to the buffer, backwards from the current location. Doesn't align nor check for space.
A utility function to copy and return the ByteBuffer data as a byte[]
.
Start encoding a new object in the buffer. Users will not usually need to call this directly. The FlatBuffers
compiler will generate helper methods that call this method internally.
Start a new array/vector of objects. Users usually will not call this directly. The FlatBuffers
compiler will create a start/end method for vector types in generated code.