diff options
author | astange <stange@google.com> | 2020-10-12 15:25:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 12:25:10 -0700 |
commit | 4ec5e8db9049c6568ffc50ba97fab24bc9e50eff (patch) | |
tree | d0f05bd6a13083f49d6ad6349fdc2ebed549e3c1 /src | |
parent | 04bec23a37e11a80b9c6dc56657654305d658691 (diff) | |
download | flatbuffers-4ec5e8db9049c6568ffc50ba97fab24bc9e50eff.tar.gz flatbuffers-4ec5e8db9049c6568ffc50ba97fab24bc9e50eff.tar.bz2 flatbuffers-4ec5e8db9049c6568ffc50ba97fab24bc9e50eff.zip |
[C++] Add option to not generate direct copy methods. (#6166)
* Add option to not generate direct copy methods.
The direct copy methods generated by flatc utilize std::vector which isn't allowed on some embedded systems. Permit users of the compiler to not generate these methods so they don't have to be stubbed out.
* Update docs for no-cpp-direct-copy option.
Diffstat (limited to 'src')
-rw-r--r-- | src/flatc.cpp | 2 | ||||
-rw-r--r-- | src/idl_gen_cpp.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/flatc.cpp b/src/flatc.cpp index 4a77cce5..4a9df5f8 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -282,6 +282,8 @@ int FlatCompiler::Compile(int argc, const char **argv) { opts.cpp_object_api_string_type = argv[argi]; } else if (arg == "--cpp-str-flex-ctor") { opts.cpp_object_api_string_flexible_constructor = true; + } else if (arg == "--no-cpp-direct-copy") { + opts.cpp_direct_copy = false; } else if (arg == "--gen-nullable") { opts.gen_nullable = true; } else if (arg == "--java-checkerframework") { diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 5b5d978d..72f9a88e 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -2398,7 +2398,7 @@ class CppGenerator : public BaseGenerator { } // Generate a CreateXDirect function with vector types as parameters - if (has_string_or_vector_fields) { + if (opts_.cpp_direct_copy && has_string_or_vector_fields) { code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> " "Create{{STRUCT_NAME}}Direct("; |