mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 23:40:57 +00:00
Various documentation clarifications.
Change-Id: Ibc2bd88a636f3b4abf82a7c2722fc1e354dab848 Tested: on Linux.
This commit is contained in:
@@ -82,7 +82,7 @@ parent object, and use no virtual table).
|
||||
|
||||
### Types
|
||||
|
||||
Builtin scalar types are:
|
||||
Built-in scalar types are:
|
||||
|
||||
- 8 bit: `byte ubyte bool`
|
||||
|
||||
@@ -92,6 +92,8 @@ Builtin scalar types are:
|
||||
|
||||
- 64 bit: `long ulong double`
|
||||
|
||||
Built-in non-scalar types:
|
||||
|
||||
- Vector of any other type (denoted with `[type]`). Nesting vectors
|
||||
is not supported, instead you can wrap the inner vector in a table.
|
||||
|
||||
@@ -137,6 +139,14 @@ additionally a hidden field with the suffix `_type` is generated that
|
||||
holds the corresponding enum value, allowing you to know which type to
|
||||
cast to at runtime.
|
||||
|
||||
Unions are a good way to be able to send multiple message types as a FlatBuffer.
|
||||
Note that because a union field is really two fields, it must always be
|
||||
part of a table, it cannot be the root of a FlatBuffer by itself.
|
||||
|
||||
If you have a need to distinguish between different FlatBuffers in a more
|
||||
open-ended way, for example for use as files, see the file identification
|
||||
feature below.
|
||||
|
||||
### Namespaces
|
||||
|
||||
These will generate the corresponding namespace in C++ for all helper
|
||||
@@ -195,6 +205,10 @@ without one, you can always still do so by calling
|
||||
After loading a buffer, you can use a call like
|
||||
`MonsterBufferHasIdentifier` to check if the identifier is present.
|
||||
|
||||
Note that this is best for open-ended uses such as files. If you simply wanted
|
||||
to send one of a set of possible messages over a network for example, you'd
|
||||
be better off with a union.
|
||||
|
||||
Additionally, by default `flatc` will output binary files as `.bin`.
|
||||
This declaration in the schema will change that to whatever you want:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user