mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-23 16:30:02 +00:00
Generate C++ function returning the file_identifier of a flatbuffer
Change-Id: I6ee09cf1e86a41b73bb3aa79b68871afb1a4e34f
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
2d9b3ade18
commit
354fd906a5
@@ -240,9 +240,11 @@ inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<
|
||||
|
||||
inline bool VerifyMonsterBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<Monster>(); }
|
||||
|
||||
inline void FinishMonsterBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Monster> root) { fbb.Finish(root, "MONS"); }
|
||||
inline const char *MonsterIdentifier() { return "MONS"; }
|
||||
|
||||
inline bool MonsterBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, "MONS"); }
|
||||
inline bool MonsterBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, MonsterIdentifier()); }
|
||||
|
||||
inline void FinishMonsterBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Monster> root) { fbb.Finish(root, MonsterIdentifier()); }
|
||||
|
||||
} // namespace Example
|
||||
} // namespace MyGame
|
||||
|
||||
@@ -117,6 +117,7 @@ void AccessFlatBufferTest(const std::string &flatbuf) {
|
||||
flatbuf.length());
|
||||
TEST_EQ(VerifyMonsterBuffer(verifier), true);
|
||||
|
||||
TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0);
|
||||
TEST_EQ(MonsterBufferHasIdentifier(flatbuf.c_str()), true);
|
||||
|
||||
// Access the buffer from the root.
|
||||
|
||||
Reference in New Issue
Block a user