FlatBufferBuilder

Class that helps you build a FlatBuffer. See the section "Use in Java/C#" in the main FlatBuffers documentation.

Constructors

Link copied to clipboard
constructor(initial_size: Int, bb_factory: FlatBufferBuilder.ByteBufferFactory)
Start with a buffer of size `initial_size`, then grow as required.
constructor(initial_size: Int, bb_factory: FlatBufferBuilder.ByteBufferFactory, existing_bb: ByteBuffer, utf8: Utf8)
Start with a buffer of size `initial_size`, then grow as required.
constructor(initial_size: Int)
Start with a buffer of size `initial_size`, then grow as required.
constructor()
Start with a buffer of 1KiB, then grow as required.
constructor(existing_bb: ByteBuffer, bb_factory: FlatBufferBuilder.ByteBufferFactory)
Alternative constructor allowing reuse of ByteBuffers.
constructor(existing_bb: ByteBuffer)
Alternative constructor allowing reuse of ByteBuffers.

Types

Link copied to clipboard
abstract class ByteBufferFactory
An interface that provides a user of the FlatBufferBuilder class the ability to specify the method in which the internal buffer gets allocated.
Link copied to clipboard
An implementation of the ByteBufferFactory interface that is used when one is not provided by the user.

Functions

Link copied to clipboard
open fun addBoolean(x: Boolean)
Add a `boolean` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addBoolean(o: Int, x: Boolean, d: Boolean)
Add a `boolean` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addByte(x: Byte)
Add a `byte` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addByte(o: Int, x: Byte, d: Int)
Add a `byte` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addDouble(x: Double)
Add a `double` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addDouble(o: Int, x: Double, d: Double)
Add a `double` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addFloat(x: Float)
Add a `float` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addFloat(o: Int, x: Float, d: Double)
Add a `float` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addInt(x: Int)
Add an `int` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addInt(o: Int, x: Int, d: Int)
Add an `int` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addLong(x: Long)
Add a `long` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addLong(o: Int, x: Long, d: Long)
Add a `long` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addOffset(off: Int)
Adds on offset, relative to where it will be written.
open fun addOffset(o: Int, x: Int, d: Int)
Add an `offset` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addShort(x: Short)
Add a `short` to the buffer, properly aligned, and grows the buffer (if necessary).
open fun addShort(o: Int, x: Short, d: Int)
Add a `short` to a table at `o` into its vtable, with value `x` and default `d`.
Link copied to clipboard
open fun addStruct(voffset: Int, x: Int, d: Int)
Add a struct to the table.
Link copied to clipboard
open fun clear()
Reset the FlatBufferBuilder by purging all data that it holds.
Link copied to clipboard
open fun createByteVector(arr: Array<Byte>): Int
open fun createByteVector(byteBuffer: ByteBuffer): Int
open fun createByteVector(arr: Array<Byte>, offset: Int, length: Int): Int
Create a byte array in the buffer.
Link copied to clipboard
open fun <T : Table?> createSortedVectorOfTables(obj: T, offsets: Array<Int>): Int
Create a vector of sorted by the key tables.
Link copied to clipboard
Encode the string `s` in the buffer using UTF-8.
Create a string in the buffer from an already encoded UTF-8 string in a ByteBuffer.
Link copied to clipboard
open fun createUnintializedVector(elem_size: Int, num_elems: Int, alignment: Int): ByteBuffer
Create a new array/vector and return a ByteBuffer to be filled later.
Link copied to clipboard
open fun createVectorOfTables(offsets: Array<Int>): Int
Create a vector of tables.
Link copied to clipboard
Get the ByteBuffer representing the FlatBuffer.
Link copied to clipboard
open fun endObject(): Int
Finish off writing the object that is under construction.
Link copied to clipboard
open fun endVector(): Int
Finish off the creation of an array and all its elements.
Link copied to clipboard
open fun finish(root_table: Int)
open fun finish(root_table: Int, file_identifier: String)
Finalize a buffer, pointing to the given `root_table`.
Link copied to clipboard
open fun finished()
Should not be accessing the final buffer before it is finished.
Link copied to clipboard
open fun finishSizePrefixed(root_table: Int)
open fun finishSizePrefixed(root_table: Int, file_identifier: String)
Finalize a buffer, pointing to the given `root_table`, with the size prefixed.
Link copied to clipboard
open fun forceDefaults(forceDefaults: Boolean): FlatBufferBuilder
In order to save space, fields that are set to their default value don't get serialized into the buffer.
Link copied to clipboard
Alternative initializer that allows reusing this object on an existing `ByteBuffer`.
Link copied to clipboard
open fun isFieldPresent(table: Table, offset: Int): Boolean
Helper function to test if a field is present in the table
Link copied to clipboard
open fun Nested(obj: Int)
Structures are always stored inline, they need to be created right where they're used.
Link copied to clipboard
open fun notNested()
Should not be creating any other object, string or vector while an object is being constructed.
Link copied to clipboard
open fun offset(): Int
Offset relative to the end of the buffer.
Link copied to clipboard
open fun pad(byte_size: Int)
Add zero valued bytes to prepare a new entry to be added.
Link copied to clipboard
open fun prep(size: Int, additional_bytes: Int)
Prepare to write an element of `size` after `additional_bytes` have been written, e.g.
Link copied to clipboard
open fun putBoolean(x: Boolean)
Add a `boolean` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putByte(x: Byte)
Add a `byte` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putDouble(x: Double)
Add a `double` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putFloat(x: Float)
Add a `float` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putInt(x: Int)
Add an `int` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putLong(x: Long)
Add a `long` to the buffer, backwards from the current location.
Link copied to clipboard
open fun putShort(x: Short)
Add a `short` to the buffer, backwards from the current location.
Link copied to clipboard
open fun required(table: Int, field: Int)
Checks that a required field has been set in a given table that has just been constructed.
Link copied to clipboard
A utility function to copy and return the ByteBuffer data as a `byte[]`.
open fun sizedByteArray(start: Int, length: Int): Array<Byte>
A utility function to copy and return the ByteBuffer data from `start` to `start` + `length` as a `byte[]`.
Link copied to clipboard
A utility function to return an InputStream to the ByteBuffer data
Link copied to clipboard
open fun slot(voffset: Int)
Set the current vtable at `voffset` to the current location in the buffer.
Link copied to clipboard
open fun startObject(numfields: Int)
Start encoding a new object in the buffer.
Link copied to clipboard
open fun startVector(elem_size: Int, num_elems: Int, alignment: Int)
Start a new array/vector of objects.