2015-12-04 04:30:54 +00:00
|
|
|
Using the schema compiler {#flatbuffers_guide_using_schema_compiler}
|
|
|
|
=========================
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
2019-06-09 19:30:10 +00:00
|
|
|
flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] FILES...
|
2014-07-11 21:01:55 +00:00
|
|
|
[ -- FILES...]
|
2014-01-28 00:52:49 +00:00
|
|
|
|
|
|
|
The files are read and parsed in order, and can contain either schemas
|
2015-12-01 00:42:48 +00:00
|
|
|
or data (see below). Data files are processed according to the definitions of
|
|
|
|
the most recent schema specified.
|
2014-07-11 21:01:55 +00:00
|
|
|
|
|
|
|
`--` indicates that the following files are binary files in
|
2015-12-01 00:42:48 +00:00
|
|
|
FlatBuffer format conforming to the schema indicated before it.
|
2014-07-11 21:01:55 +00:00
|
|
|
|
|
|
|
Depending on the flags passed, additional files may
|
2014-01-28 00:52:49 +00:00
|
|
|
be generated for each file processed:
|
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
For any schema input files, one or more generators can be specified:
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--cpp`, `-c` : Generate a C++ header for all definitions in this file (as
|
|
|
|
`filename_generated.h`).
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--java`, `-j` : Generate Java code.
|
2014-09-26 23:46:30 +00:00
|
|
|
|
2019-07-22 23:05:15 +00:00
|
|
|
- `--kotlin`, `-k` : Generate Kotlin code.
|
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--csharp`, `-n` : Generate C# code.
|
2014-09-26 23:46:30 +00:00
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--go`, `-g` : Generate Go code.
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--python`, `-p`: Generate Python code.
|
|
|
|
|
2017-03-15 22:16:43 +00:00
|
|
|
- `--js`, `-s`: Generate JavaScript code.
|
2015-11-26 01:26:34 +00:00
|
|
|
|
2018-07-24 02:03:11 +00:00
|
|
|
- `--ts`: Generate TypeScript code.
|
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
- `--php`: Generate PHP code.
|
|
|
|
|
2016-04-14 01:16:05 +00:00
|
|
|
- `--grpc`: Generate RPC stub code for GRPC.
|
|
|
|
|
Add [Dart] support (#4676)
* Add [Dart] support
* fix enum vectors
* Allow for opt out of string interning
* fix comment style, make interning opt in
* remove Offset<T>, prefer int
* avoid creating unnecessary vtable objects
* start work on tests - do not generate builder if struct has 0 fields - add int64
* support reading structs properly
* correctly handle reading vectors of structs, dartfmt
* support structs, fix unnecessary prepares
* fix bool customizations
* undo unintentional removal of file
* docs updates, complete tutorial, bug fix for codegen
* more documentation
* Update docs, add to doxygen file
* update package structure, add samples script/code
* rearrange sample
* Tests
* Add readme for pub
* cleanup package for pub
* update docs for renamed file
* remove custom matcher, use `closeTo` instead
* remove unintentional file
* remove unintended file checkin
* use auto, move method, cleanup
* refactor to ObjectBuilders, add Builders
* Update tests, examples
* Add files missing from previous commit
* documentation and example updates
* Update LICENSE, make dartanalyzer happy, fix minor bugs, get rid of duplicate files, publish script
* fix sample for slightly different schema
* Update pubspec.yaml
2018-05-18 18:06:15 +00:00
|
|
|
- `--dart`: Generate Dart code.
|
|
|
|
|
2018-07-24 02:03:11 +00:00
|
|
|
- `--lua`: Generate Lua code.
|
|
|
|
|
|
|
|
- `--lobster`: Generate Lobster code.
|
|
|
|
|
2018-09-03 00:05:50 +00:00
|
|
|
- `--rust`, `-r` : Generate Rust code.
|
|
|
|
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
- `--swift`: Generate Swift code.
|
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
For any data input files:
|
|
|
|
|
|
|
|
- `--binary`, `-b` : If data is contained in this file, generate a
|
|
|
|
`filename.bin` containing the binary flatbuffer (or a different extension
|
|
|
|
if one is specified in the schema).
|
|
|
|
|
|
|
|
- `--json`, `-t` : If data is contained in this file, generate a
|
2014-07-11 21:01:55 +00:00
|
|
|
`filename.json` representing the data in the flatbuffer.
|
2014-01-28 00:52:49 +00:00
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
Additional options:
|
|
|
|
|
2014-07-08 23:35:14 +00:00
|
|
|
- `-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 `\`.
|
|
|
|
|
2014-09-12 00:13:21 +00:00
|
|
|
- `-I PATH` : when encountering `include` statements, attempt to load the
|
|
|
|
files from this path. Paths will be tried in the order given, and if all
|
|
|
|
fail (or none are specified) it will try to load relative to the path of
|
|
|
|
the schema file being parsed.
|
|
|
|
|
2015-10-20 00:03:14 +00:00
|
|
|
- `-M` : Print make rules for generated files.
|
|
|
|
|
2015-01-17 00:57:04 +00:00
|
|
|
- `--strict-json` : Require & generate strict JSON (field names are enclosed
|
|
|
|
in quotes, no trailing commas in tables/vectors). By default, no quotes are
|
|
|
|
required/generated, and trailing commas are allowed.
|
2014-08-21 23:11:18 +00:00
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--allow-non-utf8` : Pass non-UTF-8 input through parser and emit nonstandard
|
|
|
|
\x escapes in JSON. (Default is to raise parse error on non-UTF-8 input.)
|
|
|
|
|
2021-09-15 21:57:29 +00:00
|
|
|
- `--natural-utf8` : Output strings with UTF-8 as human-readable strings.
|
2019-02-11 20:34:10 +00:00
|
|
|
By default, UTF-8 characters are printed as \uXXXX escapes."
|
|
|
|
|
2015-05-27 23:42:15 +00:00
|
|
|
- `--defaults-json` : Output fields whose value is equal to the default value
|
|
|
|
when writing JSON text.
|
|
|
|
|
2014-09-26 23:46:30 +00:00
|
|
|
- `--no-prefix` : Don't prefix enum values in generated C++ by their enum
|
|
|
|
type.
|
|
|
|
|
2015-09-15 08:11:29 +00:00
|
|
|
- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
|
|
|
|
generated C++. This also implies `--no-prefix`.
|
2023-01-07 18:33:11 +00:00
|
|
|
|
|
|
|
- `--no-emit-min-max-enum-values` : Disable generation of MIN and MAX
|
|
|
|
enumerated values for scoped enums and prefixed enums.
|
|
|
|
|
2015-08-04 18:40:45 +00:00
|
|
|
- `--gen-includes` : (deprecated), this is the default behavior.
|
|
|
|
If the original behavior is required (no include
|
|
|
|
statements) use `--no-includes.`
|
|
|
|
|
2015-06-16 03:26:10 +00:00
|
|
|
- `--no-includes` : Don't generate include statements for included schemas the
|
2019-12-02 22:11:28 +00:00
|
|
|
generated file depends on (C++ / Python).
|
2014-08-21 23:11:18 +00:00
|
|
|
|
2015-04-27 23:25:06 +00:00
|
|
|
- `--gen-mutable` : Generate additional non-const accessors for mutating
|
|
|
|
FlatBuffers in-place.
|
|
|
|
|
2021-12-09 23:47:09 +00:00
|
|
|
- `--gen-onefile` : Generate single output file for C#, Go, and Python.
|
2019-02-11 20:34:10 +00:00
|
|
|
|
|
|
|
- `--gen-name-strings` : Generate type name functions for C++.
|
|
|
|
|
|
|
|
- `--gen-object-api` : Generate an additional object-based API. This API is
|
2016-07-02 01:08:51 +00:00
|
|
|
more convenient for object construction and mutation than the base API,
|
|
|
|
at the cost of efficiency (object allocation). Recommended only to be used
|
|
|
|
if other options are insufficient.
|
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--gen-compare` : Generate operator== for object-based API types.
|
|
|
|
|
|
|
|
- `--gen-nullable` : Add Clang _Nullable for C++ pointer. or @Nullable for Java.
|
2018-09-21 23:53:59 +00:00
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--gen-generated` : Add @Generated annotation for Java.
|
2015-06-13 15:55:24 +00:00
|
|
|
|
2020-08-18 16:44:43 +00:00
|
|
|
- `--gen-jvmstatic` : Add @JvmStatic annotation for Kotlin methods
|
|
|
|
in companion object for interop from Java to Kotlin.
|
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--gen-all` : Generate not just code for the current schema files, but
|
2015-12-01 01:42:19 +00:00
|
|
|
for all files it includes as well. If the language uses a single file for
|
|
|
|
output (by default the case for C++ and JS), all code will end up in
|
|
|
|
this one file.
|
|
|
|
|
2019-05-31 20:43:30 +00:00
|
|
|
- `--cpp-include` : Adds an #include in generated file
|
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--cpp-ptr-type T` : Set object API pointer type (default std::unique_ptr)
|
2018-11-02 18:40:21 +00:00
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--cpp-str-type T` : Set object API string type (default std::string)
|
2019-03-11 16:42:02 +00:00
|
|
|
T::c_str(), T::length() and T::empty() must be supported.
|
|
|
|
The custom type also needs to be constructible from std::string (see the
|
|
|
|
--cpp-str-flex-ctor option to change this behavior).
|
|
|
|
|
|
|
|
- `--cpp-str-flex-ctor` : Don't construct custom string types by passing
|
|
|
|
std::string from Flatbuffers, but (char* + length). This allows efficient
|
|
|
|
construction of custom string types, including zero-copy construction.
|
2019-02-11 20:34:10 +00:00
|
|
|
|
2020-10-12 19:25:10 +00:00
|
|
|
- `--no-cpp-direct-copy` : Don't generate direct copy methods for C++
|
|
|
|
object-based API.
|
|
|
|
|
2019-12-23 20:13:48 +00:00
|
|
|
- `--cpp-std CPP_STD` : Generate a C++ code using features of selected C++ standard.
|
|
|
|
Supported `CPP_STD` values:
|
2020-12-07 19:19:36 +00:00
|
|
|
* `c++0x` - generate code compatible with old compilers (VS2010),
|
|
|
|
* `c++11` - use C++11 code generator (default),
|
|
|
|
* `c++17` - use C++17 features in generated code (experimental).
|
2019-12-23 20:13:48 +00:00
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--object-prefix` : Customise class prefix for C++ object-based API.
|
|
|
|
|
|
|
|
- `--object-suffix` : Customise class suffix for C++ object-based API.
|
|
|
|
|
|
|
|
- `--go-namespace` : Generate the overrided namespace in Golang.
|
|
|
|
|
|
|
|
- `--go-import` : Generate the overrided import for flatbuffers in Golang.
|
|
|
|
(default is "github.com/google/flatbuffers/go").
|
|
|
|
|
2015-05-04 20:36:27 +00:00
|
|
|
- `--raw-binary` : Allow binaries without a file_indentifier to be read.
|
|
|
|
This may crash flatc given a mismatched schema.
|
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--size-prefixed` : Input binaries are size prefixed buffers.
|
|
|
|
|
2014-09-26 23:46:30 +00:00
|
|
|
- `--proto`: Expect input files to be .proto files (protocol buffers).
|
|
|
|
Output the corresponding .fbs file.
|
2015-10-06 00:39:08 +00:00
|
|
|
Currently supports: `package`, `message`, `enum`, nested declarations,
|
|
|
|
`import` (use `-I` for paths), `extend`, `oneof`, `group`.
|
|
|
|
Does not support, but will skip without error: `option`, `service`,
|
|
|
|
`extensions`, and most everything else.
|
2015-06-16 03:26:10 +00:00
|
|
|
|
2019-02-11 20:34:10 +00:00
|
|
|
- `--oneof-union` : Translate .proto oneofs to flatbuffer unions.
|
|
|
|
|
|
|
|
- `--grpc` : Generate GRPC interfaces for the specified languages.
|
|
|
|
|
2015-06-16 03:26:10 +00:00
|
|
|
- `--schema`: Serialize schemas instead of JSON (use with -b). This will
|
|
|
|
output a binary version of the specified schema that itself corresponds
|
|
|
|
to the reflection/reflection.fbs schema. Loading this binary file is the
|
|
|
|
basis for reflection functionality.
|
2015-11-26 01:26:34 +00:00
|
|
|
|
2017-02-14 00:15:55 +00:00
|
|
|
- `--bfbs-comments`: Add doc comments to the binary schema files.
|
|
|
|
|
2016-07-21 00:24:50 +00:00
|
|
|
- `--conform FILE` : Specify a schema the following schemas should be
|
|
|
|
an evolution of. Gives errors if not. Useful to check if schema
|
|
|
|
modifications don't break schema evolution rules.
|
|
|
|
|
2019-03-11 16:42:02 +00:00
|
|
|
- `--conform-includes PATH` : Include path for the schema given with
|
2019-02-11 20:34:10 +00:00
|
|
|
`--conform PATH`.
|
|
|
|
|
2020-03-02 18:15:23 +00:00
|
|
|
- `--filename-suffix SUFFIX` : The suffix appended to the generated
|
|
|
|
file names. Default is '_generated'.
|
|
|
|
|
|
|
|
- `--filename-ext EXTENSION` : The extension appended to the generated
|
|
|
|
file names. Default is language-specific (e.g. "h" for C++). This
|
|
|
|
should not be used when multiple languages are specified.
|
|
|
|
|
2017-02-10 20:04:42 +00:00
|
|
|
- `--include-prefix PATH` : Prefix this path to any generated include
|
|
|
|
statements.
|
|
|
|
|
2017-05-10 20:21:20 +00:00
|
|
|
- `--keep-prefix` : Keep original prefix of schema include statement.
|
|
|
|
|
2017-08-25 00:44:03 +00:00
|
|
|
- `--reflect-types` : Add minimal type reflection to code generation.
|
2019-02-11 20:34:10 +00:00
|
|
|
|
2017-08-25 00:44:03 +00:00
|
|
|
- `--reflect-names` : Add minimal type/name reflection.
|
|
|
|
|
2018-05-07 23:07:52 +00:00
|
|
|
- `--root-type T` : Select or override the default root_type.
|
|
|
|
|
2020-11-20 01:16:45 +00:00
|
|
|
- `--require-explicit-ids` : When parsing schemas, require explicit ids (id: x).
|
|
|
|
|
2018-06-27 16:12:52 +00:00
|
|
|
- `--force-defaults` : Emit default values in binary output from JSON.
|
|
|
|
|
2018-07-16 23:05:06 +00:00
|
|
|
- `--force-empty` : When serializing from object API representation, force
|
|
|
|
strings and vectors to empty rather than null.
|
|
|
|
|
2019-12-06 01:33:45 +00:00
|
|
|
- `--force-empty-vectors` : When serializing from object API representation, force
|
|
|
|
vectors to empty rather than null.
|
|
|
|
|
2020-12-10 22:03:53 +00:00
|
|
|
- `--flexbuffers` : Used with "binary" and "json" options, it generates
|
|
|
|
data using schema-less FlexBuffers.
|
|
|
|
|
2021-09-15 21:57:29 +00:00
|
|
|
- `--no-warnings` : Inhibit all warning messages.
|
|
|
|
|
|
|
|
- `--cs-global-alias` : Prepend `global::` to all user generated csharp classes and structs.
|
2020-12-10 22:03:53 +00:00
|
|
|
|
2021-12-15 18:41:29 +00:00
|
|
|
- `--json-nested-bytes` : Allow a nested_flatbuffer field to be parsed as a
|
|
|
|
vector of bytes in JSON, which is unsafe unless checked by a verifier
|
|
|
|
afterwards.
|
|
|
|
|
2015-11-26 01:26:34 +00:00
|
|
|
NOTE: short-form options for generators are deprecated, use the long form
|
|
|
|
whenever possible.
|