e7399ea
.TH FLATC "1" "June 2022" "" "User Commands"
8251aff
.SH NAME
e7399ea
.B flatc
e7399ea
\(en FlatBuffers compiler
8251aff
.SH SYNOPSIS
e7399ea
.B flatc
e7399ea
.RI [ OPTION ]...\:
e7399ea
.IR FILE ...\:
e7399ea
.RI [\-\-\  FILE ...]
8251aff
.SH OPTIONS
e7399ea
.IR FILE s
e7399ea
may be schemas (must end in
e7399ea
.BR .fbs ),
e7399ea
binary schemas (must end in
e7399ea
.BR .bfbs ),
e7399ea
or JSON files (conforming to preceding schema).
e7399ea
.IR FILE s
e7399ea
after the
e7399ea
.B \-\-
e7399ea
must be binary flatbuffer format files.
e7399ea
.P
e7399ea
Output files are named using the base file name of the input,
e7399ea
and written to the current directory or the path given by
e7399ea
.BR \-o .
e7399ea
.TP
e7399ea
.B \-\-binary\fR, \fB\-b
e7399ea
Generate wire format binaries for any data definitions.
e7399ea
.TP
e7399ea
.B \-\-json\fR, \fB\-t
e7399ea
Generate text output for any data definitions.
e7399ea
.TP
e7399ea
.B \-\-cpp\fR, \fB\-c
e7399ea
Generate C++ headers for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-go\fR, \fB\-g
e7399ea
Generate Go files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-java\fR, \fB\-j
e7399ea
Generate Java classes for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-dart\fR, \fB\-d
e7399ea
Generate Dart classes for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-ts\fR, \fB\-T
e7399ea
Generate TypeScript code for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-csharp\fR, \fB\-n
e7399ea
Generate C# classes for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-python\fR, \fB\-p
e7399ea
Generate Python files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-lobster
e7399ea
Generate Lobster files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-lua\fR, \fB\-l
e7399ea
Generate Lua files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-rust\fR, \fB\-r
e7399ea
Generate Rust files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-php
e7399ea
Generate PHP files for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-kotlin
e7399ea
Generate Kotlin classes for tables/structs.
e7399ea
.TP
e7399ea
.B \-\-jsonschema
e7399ea
Generate Json schema.
e7399ea
.TP
e7399ea
.B \-\-swift
e7399ea
Generate Swift files for tables/structs.
e7399ea
.TP
e7399ea
.B \-o\ \fIPATH
e7399ea
Prefix
e7399ea
.I PATH
e7399ea
to all generated files.
e7399ea
.TP
e7399ea
.B \-I\ \fIPATH
e7399ea
Search for includes in the specified path.
e7399ea
.TP
e7399ea
.B \-M
e7399ea
Print
e7399ea
.BR make (1)
e7399ea
rules for generated files.
e7399ea
.TP
e7399ea
.B \-\-version
e7399ea
Print the version number of
e7399ea
.B flatc
e7399ea
and exit.
e7399ea
.TP
e7399ea
.B \-\-strict\-json
e7399ea
Strict JSON: field names must be\ / will be quoted,
e7399ea
no trailing commas in tables/vectors.
e7399ea
.TP
e7399ea
.B \-\-allow-non-utf8
e7399ea
Pass non-UTF-8 input through parser and emit nonstandard
e7399ea
.BI \\\\\\\\ x
e7399ea
escapes in JSON.
e7399ea
(Default is to raise parse error on non-UTF-8 input.)
e7399ea
.TP
e7399ea
.B \-\-natural\-utf8
e7399ea
Output strings with UTF-8 as human-readable strings.
e7399ea
By default, UTF-8 characters are printed as
e7399ea
.BI \\\\\\\\u XXXX
e7399ea
escapes.
e7399ea
.TP
e7399ea
.B \-\-defaults\-json
e7399ea
Output fields whose value is the default when writing JSON
e7399ea
.TP
e7399ea
.B \-\-unknown\-json
e7399ea
Allow fields in JSON that are not defined in the schema.
e7399ea
These fields will be discared when generating binaries.
e7399ea
.TP
e7399ea
.B \-\-no\-prefix
e7399ea
Don\(cqt prefix enum values with the enum type in C++.
e7399ea
.TP
e7399ea
.B \-\-scoped\-enums
e7399ea
Use C++11 style scoped and strongly typed enums.
e7399ea
Also implies
e7399ea
.BR \-\-no\-prefix .
e7399ea
.TP
e7399ea
.B \-\-gen\-includes
e7399ea
.RI ( deprecated ),
e7399ea
this is the default behavior.
e7399ea
If the original behavior is required (no include statements) use
e7399ea
.BR \-\-no\-includes .
e7399ea
.TP
e7399ea
.B \-\-no\-includes
e7399ea
Don\(cqt generate include statements for included
e7399ea
schemas the generated file depends on (C++\ / Python).
e7399ea
.TP
e7399ea
.B \-\-gen\-mutable
e7399ea
Generate accessors that can mutate buffers in-place.
e7399ea
.TP
e7399ea
.B \-\-gen\-onefile
e7399ea
Generate single output file for C# and Go.
e7399ea
.TP
e7399ea
.B \-\-gen\-name\-strings
e7399ea
Generate type name functions for C++ and Rust.
e7399ea
.TP
e7399ea
.B \-\-gen\-object\-api
e7399ea
Generate an additional object-based API.
e7399ea
.TP
e7399ea
.B \-\-gen\-compare
e7399ea
Generate
e7399ea
.B operator==
e7399ea
for object-based API types.
e7399ea
.TP
e7399ea
.B \-\-gen\-nullable
e7399ea
Add Clang
e7399ea
.B _Nullable
e7399ea
for C++ pointer. or
e7399ea
.B @Nullable
e7399ea
for Java
e7399ea
.TP
e7399ea
.B \-\-java\-checkerframework
e7399ea
Add
e7399ea
.B @Pure
e7399ea
for Java.
e7399ea
.TP
e7399ea
.B \-\-gen\-generated
e7399ea
Add
e7399ea
.B @Generated
e7399ea
annotation for Java
e7399ea
.TP
e7399ea
.B \-\-gen\-jvmstatic
e7399ea
Add
e7399ea
.B @JvmStatic
e7399ea
annotation for Kotlin methods
e7399ea
in companion object for interop from Java to Kotlin.
e7399ea
.TP
e7399ea
.B \-\-gen\-all
e7399ea
Generate not just code for the current schema files,
e7399ea
but for all files it includes as well.
e7399ea
If the language uses a single file for output (by default
e7399ea
the case for C++ and JS), all code will end up in this one file.
e7399ea
.TP
e7399ea
.B \-\-cpp\-include
e7399ea
Adds an
e7399ea
.B #include
e7399ea
in generated file.
e7399ea
.TP
e7399ea
.B \-\-cpp\-ptr\-type\ \fIT
e7399ea
Set object API pointer type
e7399ea
(default
e7399ea
.BR std::unique_ptr ).
e7399ea
.TP
e7399ea
.B \-\-cpp\-str\-type\ \fIT
e7399ea
Set object API string type
e7399ea
(default
e7399ea
.BR std::string ).
e7399ea
.BR \fIT\fB::c_str() ,
e7399ea
.BR \fIT\fB::length() ,
e7399ea
and
e7399ea
.BR \fIT\fB::empty()
e7399ea
must be supported.
e7399ea
The custom type also needs to be constructible from
e7399ea
.B std::string
e7399ea
(see the
e7399ea
.B \-\-cpp\-str\-flex\-ctor
e7399ea
option to change this behavior).
e7399ea
.TP
e7399ea
.B \-\-cpp-str-flex-ctor
e7399ea
Don\(cqt construct custom string types by passing
e7399ea
.B std::string
e7399ea
from Flatbuffers, but (\fBchar*\fR\ + \fIlength\fR).
e7399ea
.TP
e7399ea
.B \-\-cpp-std\ \fICPP_STD
e7399ea
Generate a C++ code using features of selected C++ standard.
e7399ea
.IP
e7399ea
.B Supported
e7399ea
.I CPP_STD
e7399ea
.B values:
e7399ea
.RS +7n
e7399ea
.IP \(bu 2n
e7399ea
.B c++0x
e7399ea
\(en generate code compatible with old compilers;
e7399ea
.IP \(bu 2n
e7399ea
.B c++11
e7399ea
\(en use C++11 code generator
e7399ea
.RI ( default );
e7399ea
.IP \(bu 2n
e7399ea
.B c++17
e7399ea
\(en use C++17 features in generated code
e7399ea
.RI ( experimental ).
e7399ea
.RE
e7399ea
.TP
e7399ea
.B \-\-cpp\-static\-reflection
e7399ea
When using C++17, generate extra code to provide compile-time
e7399ea
(static) reflection of Flatbuffers types.
e7399ea
Requires
e7399ea
.B \-\-cpp\-std
e7399ea
to be
e7399ea
.RB \(lq c++17 \(rq
e7399ea
or higher.
e7399ea
.TP
e7399ea
.B \-\-object\-prefix
e7399ea
Customise class prefix for C++ object-based API.
e7399ea
.TP
e7399ea
.B \-\-object\-suffix
e7399ea
Customise class suffix for C++ object-based API.
e7399ea
Default value is
e7399ea
.RB \(lq T \(rq.
e7399ea
.TP
e7399ea
.B \-\-go\-namespace
e7399ea
Generate the overriding namespace in Golang.
e7399ea
.TP
e7399ea
.B \-\-go\-import
e7399ea
Generate the overriding import for flatbuffers in Golang
e7399ea
(default is
e7399ea
.RB \(lq github.com/google/flatbuffers/go \(rq).
e7399ea
.TP
e7399ea
.B \-\-raw\-binary
e7399ea
Allow binaries without
e7399ea
.B file_identifier
e7399ea
to be read.
e7399ea
This may crash
e7399ea
.B flatc
e7399ea
given a mismatched schema.
e7399ea
.TP
e7399ea
.B \-\-size\-prefixed
e7399ea
Input binaries are size prefixed buffers.
e7399ea
.TP
e7399ea
.B \-\-proto
e7399ea
Input is a
e7399ea
.BR .proto ,
e7399ea
translate to
e7399ea
.BR .fbs .
e7399ea
.TP
e7399ea
.B \-\-proto\-namespace\-suffix\ \fISUFFIX
e7399ea
Add this namespace to any flatbuffers generated from protobufs.
e7399ea
.TP
e7399ea
.B \-\-oneof\-union
e7399ea
Translate
e7399ea
.B .proto
e7399ea
oneofs to flatbuffer unions.
e7399ea
.TP
e7399ea
.B \-\-grpc
e7399ea
Generate GRPC interfaces for the specified languages.
e7399ea
.TP
e7399ea
.B \-\-schema
e7399ea
Serialize schemas instead of JSON (use with
e7399ea
.BR \-b ).
e7399ea
.TP
e7399ea
.B \-\-bfbs\-comments
e7399ea
Add doc comments to the binary schema files.
e7399ea
.TP
e7399ea
.B \-\-bfbs\-builtins
e7399ea
Add builtin attributes to the binary schema files.
e7399ea
.TP
e7399ea
.B \-\-bfbs\-gen\-embed
e7399ea
Generate code to embed the
e7399ea
.B bfbs
e7399ea
schema to the source.
e7399ea
.TP
e7399ea
.B \-\-conform\ \fIFILE
e7399ea
Specify a schema the following schemas should be an evolution of.
e7399ea
Gives errors if not.
e7399ea
.TP
e7399ea
.B \-\-conform\-includes
e7399ea
Include path for the schema given with
e7399ea
.B \-\-conform\ \fIPATH
e7399ea
.TP
e7399ea
.B \-\-filename\-suffix
e7399ea
The suffix appended to the generated file names.
e7399ea
Default is
e7399ea
.BR \(oq _generated \(cq.
e7399ea
.TP
e7399ea
.B \-\-filename\-ext
e7399ea
The extension appended to the generated file names.
e7399ea
Default is language-specific (e.g.,
e7399ea
.RB \(oq .h \(cq
e7399ea
for C++)
e7399ea
.TP
e7399ea
.B \-\-include\-prefix\ \fIPATH
e7399ea
Prefix this path to any generated include statements.
e7399ea
.TP
e7399ea
.B \-\-keep\-prefix
e7399ea
Keep original prefix of schema include statement.
e7399ea
.TP
e7399ea
.B \-\-reflect\-types
e7399ea
Add minimal type reflection to code generation.
e7399ea
.TP
e7399ea
.B \-\-reflect\-names
e7399ea
Add minimal type/name reflection.
e7399ea
.TP
e7399ea
.B \-\-root\-type\ \fIT
e7399ea
Select or override the default root_type
e7399ea
.TP
e7399ea
.B \-\-require\-explicit\-ids
e7399ea
When parsing schemas, require explicit ids
e7399ea
.RB ( id:\ \fIx ).
e7399ea
.TP
e7399ea
.B \-\-force\-defaults
e7399ea
Emit default values in binary output from JSON
e7399ea
.TP
e7399ea
.B \-\-force\-empty
e7399ea
When serializing from object API representation,
e7399ea
force strings and vectors to empty rather than null.
e7399ea
.TP
e7399ea
.B \-\-force\-empty\-vectors
e7399ea
When serializing from object API representation,
e7399ea
force vectors to empty rather than null.
e7399ea
.TP
e7399ea
.B \-\-flexbuffers
e7399ea
Used with
e7399ea
.RB \(lq binary \(rq
e7399ea
and
e7399ea
.RB \(lq json \(rq
e7399ea
options, it generates
e7399ea
data using schema-less FlexBuffers.
e7399ea
.TP
e7399ea
.B \-\-no\-warnings
e7399ea
Inhibit all warning messages.
e7399ea
.SH EXAMPLES
e7399ea
.EX
e7399ea
.B flatc\ \-c\ \-b\ schema1.fbs\ schema2.fbs\ data.json
e7399ea
.EE
e7399ea
.SH "SEE ALSO"
e7399ea
.UR https://google.github.io/flatbuffers
e7399ea
Official documentation
e7399ea
.UE