Hi,
I had the following layout:
struct Vec2 {
x:float;
y:float;
}
table test {
points:[Vec2];
}
this generated c++ code to write into a flatbuffer that takes as argument Vec2* (pointers!). I created an array of pointers and inserted this into the right function, but the saved values were not correct. after fiddeling around I had the impression that vector of structs didn't work correctly, changing the struct to table (with some other minor changes to make it compile again) got me the right values....
I've looked at the test-code and this (from monster_test.fbs):
struct Test { a:short; b:byte; }
table Monster {
....
test4:[Test] (id: 9);
}
will generate the following methods:
(call argument to CreateMonster:)
....
flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4 = 0,
....
{
....
builder_.add_test4(test4);
....
}
and add_test4 is this:
void add_test4(flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4) { fbb_.AddOffset(22, test4); }
(note the Vector of Pointers to Test*)
does the addoffset only add the pointers and not the content of the pointer?
in the sample "test4" is only read, but never written. how would a write-call of "test4" be written?
thanks!
Kai