flatbuffer force-empty option (#4822)

This commit is contained in:
shassani
2018-07-16 16:05:06 -07:00
committed by Wouter van Oortmerssen
parent af6c0e6839
commit 51d9641de6
4 changed files with 28 additions and 6 deletions

View File

@@ -123,6 +123,8 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const {
" --reflect-names Add minimal type/name reflection.\n"
" --root-type T Select or override the default root_type\n"
" --force-defaults Emit default values in binary output from JSON\n"
" --force-empty When serializing from object API representation, "
" force strings and vectors to empty rather than null.\n"
"FILEs may be schemas (must end in .fbs), or JSON files (conforming to preceding\n"
"schema). FILEs after the -- must be binary flatbuffer format files.\n"
"Output files are named using the base file name of the input,\n"
@@ -280,6 +282,8 @@ int FlatCompiler::Compile(int argc, const char **argv) {
opts.root_type = argv[argi];
} else if (arg == "--force-defaults") {
opts.force_defaults = true;
} else if (arg == "--force-empty") {
opts.set_empty_to_null = false;
} else {
for (size_t i = 0; i < params_.num_generators; ++i) {
if (arg == params_.generators[i].generator_opt_long ||