blob: 6ed1f8a8f2a6df797b8a2eda49422c6ff9f706dc [file] [log] [blame]
<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>FlatBuffers: Using the schema compiler</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,700" rel="stylesheet">
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea" style="height: 110px;">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="commonprojectlogo">
<img alt="Logo" src="fpl_logo_small.png"/>
</td>
<td style="padding-left: 0.5em;">
<div id="projectname">FlatBuffers
</div>
<div style="font-size:12px;">
An open source project by <a href="https://developers.google.com/games/#Tools">FPL</a>.
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('flatbuffers_guide_using_schema_compiler.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Using the schema compiler </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_Compiler"></a></p>
<p>Usage: </p><pre class="fragment">flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] FILES...
[ -- FILES...]
</pre><p> The files are read and parsed in order, and can contain either schemas or data (see below). Data files are processed according to the definitions of the most recent schema specified.</p>
<p><code>--</code> indicates that the following files are binary files in FlatBuffer format conforming to the schema indicated before it.</p>
<p>Depending on the flags passed, additional files may be generated for each file processed:</p>
<p>For any schema input files, one or more generators can be specified:</p>
<ul>
<li><code>--cpp</code>, <code>-c</code> : Generate a C++ header for all definitions in this file (as <code>filename_generated.h</code>).</li>
<li><code>--java</code>, <code>-j</code> : Generate Java code.</li>
<li><code>--kotlin</code>, <code>-k</code> : Generate Kotlin code.</li>
<li><code>--csharp</code>, <code>-n</code> : Generate C# code.</li>
<li><code>--go</code>, <code>-g</code> : Generate Go code.</li>
<li><code>--python</code>, <code>-p</code>: Generate Python code.</li>
<li><code>--js</code>, <code>-s</code>: Generate JavaScript code.</li>
<li><code>--ts</code>: Generate TypeScript code.</li>
<li><code>--php</code>: Generate PHP code.</li>
<li><code>--grpc</code>: Generate RPC stub code for GRPC.</li>
<li><code>--dart</code>: Generate Dart code.</li>
<li><code>--lua</code>: Generate Lua code.</li>
<li><code>--lobster</code>: Generate Lobster code.</li>
<li><code>--rust</code>, <code>-r</code> : Generate Rust code.</li>
<li><code>--swift</code>: Generate Swift code.</li>
</ul>
<p>For any data input files:</p>
<ul>
<li><code>--binary</code>, <code>-b</code> : If data is contained in this file, generate a <code>filename.bin</code> containing the binary flatbuffer (or a different extension if one is specified in the schema).</li>
<li><code>--json</code>, <code>-t</code> : If data is contained in this file, generate a <code>filename.json</code> representing the data in the flatbuffer.</li>
</ul>
<p>Additional options:</p>
<ul>
<li><code>-o PATH</code> : 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. <code>/</code> or <code>\</code>.</li>
<li><code>-I PATH</code> : when encountering <code>include</code> 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.</li>
<li><code>-M</code> : Print make rules for generated files.</li>
<li><code>--strict-json</code> : Require &amp; 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.</li>
<li><code>--allow-non-utf8</code> : 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.)</li>
<li><code>--natural-utf8</code> : Output strings with UTF-8 as human-readable strings. By default, UTF-8 characters are printed as \uXXXX escapes."</li>
<li><code>--defaults-json</code> : Output fields whose value is equal to the default value when writing JSON text.</li>
<li><code>--no-prefix</code> : Don't prefix enum values in generated C++ by their enum type.</li>
<li><code>--scoped-enums</code> : Use C++11 style scoped and strongly typed enums in generated C++. This also implies <code>--no-prefix</code>.</li>
<li><code>--gen-includes</code> : (deprecated), this is the default behavior. If the original behavior is required (no include statements) use <code>--no-includes.</code></li>
<li><code>--no-includes</code> : Don't generate include statements for included schemas the generated file depends on (C++ / Python).</li>
<li><code>--gen-mutable</code> : Generate additional non-const accessors for mutating FlatBuffers in-place.</li>
<li><code>--gen-onefile</code> : Generate single output file for C# and Go.</li>
<li><code>--gen-name-strings</code> : Generate type name functions for C++.</li>
<li><code>--gen-object-api</code> : Generate an additional object-based API. This API is 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.</li>
<li><code>--gen-compare</code> : Generate operator== for object-based API types.</li>
<li><code>--gen-nullable</code> : Add Clang _Nullable for C++ pointer. or @Nullable for Java.</li>
<li><code>--gen-generated</code> : Add @Generated annotation for Java.</li>
<li><code>--gen-jvmstatic</code> : Add @JvmStatic annotation for Kotlin methods in companion object for interop from Java to Kotlin.</li>
<li><code>--gen-all</code> : Generate not just code for the current schema files, but 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.</li>
<li><code>--cpp-include</code> : Adds an include in generated file</li>
<li><code>--cpp-ptr-type T</code> : Set object API pointer type (default std::unique_ptr)</li>
<li><code>--cpp-str-type T</code> : Set object API string type (default std::string) T::c_str(), T::length() and T::empty() must be supported. The custom type also needs to be constructible from std::string (see the &ndash;cpp-str-flex-ctor option to change this behavior).</li>
<li><code>--cpp-str-flex-ctor</code> : 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.</li>
<li><code>--no-cpp-direct-copy</code> : Don't generate direct copy methods for C++ object-based API.</li>
<li><code>--cpp-std CPP_STD</code> : Generate a C++ code using features of selected C++ standard. Supported <code>CPP_STD</code> values:<ul>
<li><code>c++0x</code> - generate code compatible with old compilers (VS2010),</li>
<li><code>c++11</code> - use C++11 code generator (default),</li>
<li><code>c++17</code> - use C++17 features in generated code (experimental).</li>
</ul>
</li>
<li><code>--object-prefix</code> : Customise class prefix for C++ object-based API.</li>
<li><code>--object-suffix</code> : Customise class suffix for C++ object-based API.</li>
<li><code>--go-namespace</code> : Generate the overrided namespace in Golang.</li>
<li><code>--go-import</code> : Generate the overrided import for flatbuffers in Golang. (default is "github.com/google/flatbuffers/go").</li>
<li><code>--raw-binary</code> : Allow binaries without a file_indentifier to be read. This may crash flatc given a mismatched schema.</li>
<li><code>--size-prefixed</code> : Input binaries are size prefixed buffers.</li>
<li><code>--proto</code>: Expect input files to be .proto files (protocol buffers). Output the corresponding .fbs file. Currently supports: <code>package</code>, <code>message</code>, <code>enum</code>, nested declarations, <code>import</code> (use <code>-I</code> for paths), <code>extend</code>, <code>oneof</code>, <code>group</code>. Does not support, but will skip without error: <code>option</code>, <code>service</code>, <code>extensions</code>, and most everything else.</li>
<li><code>--oneof-union</code> : Translate .proto oneofs to flatbuffer unions.</li>
<li><code>--grpc</code> : Generate GRPC interfaces for the specified languages.</li>
<li><code>--schema</code>: 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.</li>
<li><code>--bfbs-comments</code>: Add doc comments to the binary schema files.</li>
<li><code>--conform FILE</code> : 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.</li>
<li><code>--conform-includes PATH</code> : Include path for the schema given with <code>--conform PATH</code>.</li>
<li><code>--filename-suffix SUFFIX</code> : The suffix appended to the generated file names. Default is '_generated'.</li>
<li><code>--filename-ext EXTENSION</code> : 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.</li>
<li><code>--include-prefix PATH</code> : Prefix this path to any generated include statements.</li>
<li><code>--keep-prefix</code> : Keep original prefix of schema include statement.</li>
<li><code>--reflect-types</code> : Add minimal type reflection to code generation.</li>
<li><code>--reflect-names</code> : Add minimal type/name reflection.</li>
<li><code>--root-type T</code> : Select or override the default root_type.</li>
<li><code>--require-explicit-ids</code> : When parsing schemas, require explicit ids (id: x).</li>
<li><code>--force-defaults</code> : Emit default values in binary output from JSON.</li>
<li><code>--force-empty</code> : When serializing from object API representation, force strings and vectors to empty rather than null.</li>
<li><code>--force-empty-vectors</code> : When serializing from object API representation, force vectors to empty rather than null.</li>
<li><code>--flexbuffers</code> : Used with "binary" and "json" options, it generates data using schema-less FlexBuffers.</li>
<li><code>--no-warnings</code> : Inhibit all warning messages.</li>
</ul>
<p>NOTE: short-form options for generators are deprecated, use the long form whenever possible. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-49880327-7', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>