Comments (10)
Any table can be a root in a buffer. The root type is mostly for use by JSON, which doesn't specify any types, so we need to know where to start. The generated GetRoot functions are merely convenience.
from flatbuffers.
Ok, thanks. But in Java,
- If i have a ByteBuffer of a non root table how do read that using FlatBuffersBuilder. The only way I know is to use the __init() function, is there another way?
- Is there a way to know the type of the table from the binary data?
- How to use the addXXXType function, in your JavaTest.java you used: Monster.addTestType(fbb, (byte)1); how do you get the type of a table, in this case 1 which it is hard-coded ?
from flatbuffers.
-
a commit was pushed yesterday that adds GetRootAs functions for all tables, not just the root_type.
-
generally no. this is a strongly types system, meaning you need to know the kind of buffer you're dealing with. If you want to use this in a context where you want to have multiple different root types, you have these options:
a) make your root type a table that contains a union of all possible sub-roots.
b) prefix flatbuffers with your own file header
c) use flatbuffer's built-in file indentification feature, which hasn't been ported to Java yet. I'll get to that. -
That's a bug, the
1
should actually read:Any.Monster
. I'll fix that.
from flatbuffers.
Thanks
- But i think the name should be just "get" or "init" instead of getRootAs
from flatbuffers.
getRootAs
is a bit more descriptive and less likely to clash with other identifiers. I think I'll keep it for now.
To further my response to your issue #2, the built-in file_identifier functionality is now also available in Java. See the Schema docs, Java docs, and Java code.
from flatbuffers.
So... How do I access non root_type buffers, can't find anything like Get*** in c++ generated files and the same problem in go lang.
generated code has huge differencies between languages and it's really hard to work with
from flatbuffers.
Tried both latest master and latest release versions
from flatbuffers.
In C++ there is the GetRoot templated function that works with any table type.
Go appears to still be pending on: #363
from flatbuffers.
please explain me how to build flatc executable?
from flatbuffers.
@gaurimaheshwari : https://google.github.io/flatbuffers/flatbuffers_guide_building.html
from flatbuffers.
Related Issues (20)
- [Java, FlatBuffers 23.5.26, Mac OS 14.3] getByKey returns null while accessing using vector index works
- `get_root_as_*` functions not generated [Rust, 23.5.26, Linux] HOT 1
- Generating schemas with language adapters (as optional add-ons)?
- Streaming flatbuffers in java HOT 1
- [TS] optional escalar not set in the binary when it holds value 0 HOT 13
- Release a new version, please HOT 1
- Default value of 0 for field is not part of [optional] enum (java)
- Buffer generated in python gets rejected by flatcc [Python / C, Flatbuffer 23.5.26]
- Invalid Code generation if Property has same name as Struct [Windows/C#/24.3.7]
- v24.3.7 of Rust crate not released to crates.io HOT 4
- [v24.3.7] Rust: push_u8_u64_alignment test fails on i686 target (Ubuntu 22.04, CentOS 9)
- How to print nested table using FlatBufferToString?
- [Python] Flatc stub compatibility with gRPC asyncio Interface
- [Rust] Add better support for "crate-per-schema" HOT 2
- [Bazel CI] Swift toolchain analysis failed due to missing 'swift' configuration fragment HOT 1
- [C#][Feature Request] Unity Game Development needs mutate fixed size string value HOT 2
- Generated CreateXDirect with std::span<T> or "T* + size" payloads
- newbie's question.. use in c# / vector struct / adding int64...
- Feature: --gen-object-api support for Kotlin [Kotlin, FlatBuffers 24.3.25]
- [Rust] inconsistent nested_flatbuffers validations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flatbuffers.