反序列化表示非根表的FlatBuffers二进制文件 [英] Deserialize flatbuffers binary that represents non-root table
问题描述
是否可以反序列化表示非根表的二进制Flatbuffers对象?
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;
假设我们可以访问表示Foo
对象的二进制数据.是否可以将此二进制文件反序列化为类Foo
的对象?查看我的c ++生成的头文件,看不到任何生成的函数,例如GetFoo()
.
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()
.
推荐答案
GetFoo
只是调用GetRoot<Foo>
的已声明root_type
的便捷功能,您可以使用GetRoot<Bar>
来访问任何类型的根目录,假设缓冲区是这样构造的.
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.
这篇关于反序列化表示非根表的FlatBuffers二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!