My understanding is that root type is some legacy thing, it is needed only for two reasons:
- root_type name (name, not content) is used to create some objects, for example embed binary schema.
- some syntax sugar API is generated only for root type. Since it is just sugar, you don't have to use it.
Am I right or am I missing something?
So for example if I do:
table Foo { ... }
table Bar {...}
...
// empty root at the end to make flatbuffers happy
table Fbs {}
root_type Fbs
I named it Fbs so that generated schema looks nice: FbsBinarySchema.
Another option would be to use file name, since it contains binary schema of full file, and thus MyFileBinarySchema makes sense.
The
root_typeis very important for flatbuffers and is not a legacy thing.It is used to know the type of the table referenced by the buffer, so it knows how to decode its contents.
Currently in your schema, no
FooorBartables are accessible. You need to add them to yourFbstable:So you should have a generated accessor:
That allows you to get the root type/table. From there, all other things in the buffer are referenceable from the root type.