diff --git a/docs/html/md__compiler.html b/docs/html/md__compiler.html index 21bd4d476..512979137 100644 --- a/docs/html/md__compiler.html +++ b/docs/html/md__compiler.html @@ -53,13 +53,15 @@ $(document).ready(function(){initNavTree('md__compiler.html','');});
Usage:
flatc [ -c ] [ -j ] [ -b ] [ -t ] file1 file2 .. +Usage:
flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -S ] file1 file2 ..The files are read and parsed in order, and can contain either schemas or data (see below). Later files can make use of definitions in earlier files. Depending on the flags passed, additional files may be generated for each file processed:
-c
: Generate a C++ header for all definitions in this file (asfilename_generated.h
). Skips data.-j
: Generate Java classes.- -
-b
: If data is contained in this file, generate afilename_wire.bin
containing the binary flatbuffer.- +
-t
: If data is contained in this file, generate afilename_wire.txt
(for debugging).- +
-t
: If data is contained in this file, generate afilename_wire.txt
(for debugging).- +
-o PATH
: Output all generated files to PATH (either absolute, or relative to the current directory). If omitted, PATH will be the current directory. PATH should end in your systems path separator, e.g./
or\
.-S
: Generate strict JSON (field names are enclosed in quotes). By default, no quotes are generated.
Tables are the main way of defining objects in FlatBuffers, and consist of a name (here Monster
) and a list of fields. Each field has a name, a type, and optionally a default value (if omitted, it defaults to 0 / NULL).
Each field is optional: It does not have to appear in the wire representation, and you can choose to omit fields for each individual object. As a result, you have the flexibility to add fields without fear of bloating your data. This design is also FlatBuffer's mechanism for forward and backwards compatibility. Note that:
id
attribute below.id
attribute below.deprecated
as in the example above, which will prevent the generation of accessors in the generated C++, as a way to enforce the field not being used any more. (careful: this may break code!).Attributes may be attached to a declaration, behind a field, or after the name of a table/struct/enum/union. These may either have a value or not. Some attributes like deprecated
are understood by the compiler, others are simply ignored (like priority
), but are available to query if you parse the schema at runtime. This is useful if you write your own code generators/editors etc., and you wish to add additional information specific to your tool (such as a help text).
Current understood attributes:
id: n
(on a table field): manually set the field id to n
. If you use this attribute, you must use it on ALL fields of this table, and the numbers must be a contiguous range from 0 onwards. Additionally, since a union type effectively adds two fields, its id must be that of the second field (the first field is the type field and not explicitly declared in the schema). Once you've added id's, you can now order fields in any order in the schema, though new fields must still use the next available id when added.id: n
(on a table field): manually set the field identifier to n
. If you use this attribute, you must use it on ALL fields of this table, and the numbers must be a contiguous range from 0 onwards. Additionally, since a union type effectively adds two fields, its id must be that of the second field (the first field is the type field and not explicitly declared in the schema). For example, if the last field before the union field had id 6, the union field should have id 8, and the unions type field will implicitly be 7. IDs allow the fields to be placed in any order in the schema. When a new field is added to the schema is must use the next available ID.deprecated
(on a field): do not generate accessors for this field anymore, code should stop using this data.original_order
(on a table): since elements in a table do not need to be stored in any particular order, they are often optimized for space by sorting them to size. This attribute stops that from happening.force_align: size
(on a struct): force the alignment of this struct to be something higher than what it is naturally aligned to. Causes these structs to be aligned to that amount inside a buffer, IF that buffer is allocated with that alignment (which is not necessarily the case for buffers accessed directly inside a FlatBufferBuilder
).