mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 08:18:19 +00:00
Add constant accessors to C++ unions (#4433)
* Add constant accessors to C++ unions * Remove redundant const pointer return type * Update generate_code.bat to reflect generate_code.sh * Add updated generated files * Remove extra space from generated code * Update generated files * Change directory back to tests after generating code
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
28920aff8f
commit
21a8121982
@@ -162,14 +162,26 @@ struct AnyUnion {
|
||||
return type == Any_Monster ?
|
||||
reinterpret_cast<MonsterT *>(value) : nullptr;
|
||||
}
|
||||
const MonsterT *AsMonster() const {
|
||||
return type == Any_Monster ?
|
||||
reinterpret_cast<const MonsterT *>(value) : nullptr;
|
||||
}
|
||||
TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() {
|
||||
return type == Any_TestSimpleTableWithEnum ?
|
||||
reinterpret_cast<TestSimpleTableWithEnumT *>(value) : nullptr;
|
||||
}
|
||||
const TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() const {
|
||||
return type == Any_TestSimpleTableWithEnum ?
|
||||
reinterpret_cast<const TestSimpleTableWithEnumT *>(value) : nullptr;
|
||||
}
|
||||
MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() {
|
||||
return type == Any_MyGame_Example2_Monster ?
|
||||
reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
|
||||
}
|
||||
const MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() const {
|
||||
return type == Any_MyGame_Example2_Monster ?
|
||||
reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type);
|
||||
|
||||
Reference in New Issue
Block a user