Hello
Say i parse a flatbuffers from the wire.
Now I have an immutable array of bytes. For simplicity, say
std::vector<char> bytes;
Great.
I can get the top level Table type via
auto t = GetMutableRoot<T>(bytes.data())
and call appropriate methods like
t->fireMonster()
However, I want to save a nested table to disk and I'm not sure how to get the byte range from the underlying 'bytes` array.
For example:
Table Foo {
x: uint;
y: uint;
z: [ ubyte ];
}
Table Bar {
key: uint;
many_foo: [ Foo ];
}
// top level
Table Baz {
key2: uint;
many_bar: [ Bar ];
}
How do i get the size of a Foo()
In this example, i have to manually do something like:
sizeof( uint32_t ) /* x */ + sizeof ( uint32_t ) /* y */ + t->z().size() /* flatbuffers::Vector<uint8_t> */;
etc.
Is there a generic way to get the 'size' of a table ?
Second question.
Assuming i have the example above, indeed the underlying ` bytes ` is for this example a std::vector < char >;
Is there a way to share a subset of the ` bytes ` array so I don't have to memcpy each Foo into a new buffer that I can then pass around to disk ?
Thanks, I've been looking through the API and couldn't find an answer to either.
Any guidance is appreciated.
The real use case is to write transaction fragments ( key=value pairs) to disk, but the example above should suffice.
THanks again!