Deserialize flatbuffers binary that represents non-root table

天涯浪子 提交于 2019-12-13 01:33:25

问题


Is it possible to deserialize a binary flatbuffers object that represents a non-root table?

Suppose the following flatbuffers schema:

table Foo {
    ...
}
table Bar {
    value:[Foo];
}
root_type Bar;

Suppose we have access to the binary data that represents the Foo object. Is it possible to deserialize this binary to an object of class Foo? Looking at my c++ generated header file, I do not see any generated function like GetFoo().


回答1:


GetFoo is just a convenience function for the declared root_type that calls GetRoot<Foo>, you can use GetRoot<Bar> to access any type as the root, assuming the buffer was constructed as such.



来源:https://stackoverflow.com/questions/51806080/deserialize-flatbuffers-binary-that-represents-non-root-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!