startTable

fun startTable(numFields: Int)

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.

For example, using the "Monster" code found on the "landing page". An object of type Monster can be created using the following code:

`int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] {
fbb.createString("test1"),
fbb.createString("test2")
});

Monster.startMonster(fbb);
Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
Color.Green, (short)5, (byte)6));
Monster.addHp(fbb, (short)80);
Monster.addName(fbb, str);
Monster.addInventory(fbb, inv);
Monster.addTestType(fbb, (byte)Any.Monster);
Monster.addTest(fbb, mon2);
Monster.addTest4(fbb, test4);
Monster.addTestarrayofstring(fbb, testArrayOfString);
int mon = Monster.endMonster(fbb);
`
*

Here:

  • The call to Monster#startMonster(FlatBufferBuilder) will call this method with the right number of fields set.

  • Monster#endMonster(FlatBufferBuilder) will ensure .endObject is called.

It's not recommended to call this method directly. If it's called manually, you must ensure to audit all calls to it whenever fields are added or removed from your schema. This is automatically done by the code generated by the FlatBuffers compiler.

Parameters

numFields

The number of fields found in this object.