Flatbuffers - object API - Array of pointers for efficiency?

160 Views Asked by At

given the following schema, using object APi in C++,

include "link_to_sub.fbs";
namespace My_namespace;


table My_tables {

    list : [ namespace.of.Table ] (required, native_inline);

}

root_type My_tables;

In the generated file by flac, I end up with a vector of TableT in My_tablesT, which is expected, defined as:

vector<namespace::of::TableT> list{}

I would like

vector<namespace::of::TableT*> list{}

instead, because I already have TableT somewhere in memory. That avoids one full copy.

Note: I want to keep using the c++ object api, much easier.

Note2: the context is on-the-fly flatbuffer creation, so they are dynamically created with differing data from already existing sources.

How can I do that, how can I tell flatc to generate a vector of pointers instead ?

Thanks

1

There are 1 best solutions below

0
On

Got it:

cpp_ptr_type: "naked"

on the field.

Nice.