C++ Feature: Mutable union getters (#8852)

* generate mutable union accessors

* add test

* Revert "add test"

This reverts commit 45e352b18f.

* update file

* formatter got in the way

* merge conflicts

* updated genned code

* manually fix code gen bc I can't figure out why this file won't code gen

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
Justin Davis
2025-12-21 17:36:47 -05:00
committed by GitHub
parent b1e7868db6
commit 7cb0bcb212
11 changed files with 375 additions and 8 deletions

View File

@@ -1481,6 +1481,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
return test_type() == MyGame::Example::Any::MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
}
template<typename T> T *mutable_test_as();
MyGame::Example::Monster *mutable_test_as_Monster() {
return test_type() == MyGame::Example::Any::Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
return test_type() == MyGame::Example::Any::TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
}
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
return test_type() == MyGame::Example::Any::MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
}
void *mutable_test() {
return GetPointer<void *>(VT_TEST);
}
@@ -1716,6 +1726,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *any_unique_as_M2() const {
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
}
template<typename T> T *mutable_any_unique_as();
MyGame::Example::Monster *mutable_any_unique_as_M() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases::TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
}
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
}
void *mutable_any_unique() {
return GetPointer<void *>(VT_ANY_UNIQUE);
}
@@ -1734,6 +1754,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
void *mutable_any_ambiguous() {
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
}
@@ -2008,26 +2037,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
return test_as_Monster();
}
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
return mutable_test_as_Monster();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return test_as_TestSimpleTableWithEnum();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_test_as_TestSimpleTableWithEnum();
}
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
return test_as_MyGame_Example2_Monster();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
return mutable_test_as_MyGame_Example2_Monster();
}
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
return any_unique_as_M();
}
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
return mutable_any_unique_as_M();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return any_unique_as_TS();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_any_unique_as_TS();
}
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
return any_unique_as_M2();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
return mutable_any_unique_as_M2();
}
struct MonsterBuilder {
typedef Monster Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -595,6 +595,24 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const ::flatbuffers::String *main_character_as_Unused() const {
return main_character_type() == Character::Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
}
Attacker *mutable_main_character_as_MuLan() {
return main_character_type() == Character::MuLan ? static_cast<Attacker *>(mutable_main_character()) : nullptr;
}
Rapunzel *mutable_main_character_as_Rapunzel() {
return main_character_type() == Character::Rapunzel ? static_cast<Rapunzel *>(mutable_main_character()) : nullptr;
}
BookReader *mutable_main_character_as_Belle() {
return main_character_type() == Character::Belle ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
}
BookReader *mutable_main_character_as_BookFan() {
return main_character_type() == Character::BookFan ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
}
::flatbuffers::String *mutable_main_character_as_Other() {
return main_character_type() == Character::Other ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
}
::flatbuffers::String *mutable_main_character_as_Unused() {
return main_character_type() == Character::Unused ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
}
void *mutable_main_character() {
return GetPointer<void *>(VT_MAIN_CHARACTER);
}

View File

@@ -1497,6 +1497,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
}
template<typename T> T *mutable_test_as();
MyGame::Example::Monster *mutable_test_as_Monster() {
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
}
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
}
void *mutable_test() {
return GetPointer<void *>(VT_TEST);
}
@@ -1732,6 +1742,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *any_unique_as_M2() const {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
}
template<typename T> T *mutable_any_unique_as();
MyGame::Example::Monster *mutable_any_unique_as_M() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
}
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
}
void *mutable_any_unique() {
return GetPointer<void *>(VT_ANY_UNIQUE);
}
@@ -1750,6 +1770,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
void *mutable_any_ambiguous() {
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
}
@@ -1959,26 +1988,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
return test_as_Monster();
}
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
return mutable_test_as_Monster();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return test_as_TestSimpleTableWithEnum();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_test_as_TestSimpleTableWithEnum();
}
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
return test_as_MyGame_Example2_Monster();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
return mutable_test_as_MyGame_Example2_Monster();
}
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
return any_unique_as_M();
}
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
return mutable_any_unique_as_M();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return any_unique_as_TS();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_any_unique_as_TS();
}
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
return any_unique_as_M2();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
return mutable_any_unique_as_M2();
}
struct MonsterBuilder {
typedef Monster Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
}
template<typename T> T *mutable_test_as();
MyGame::Example::Monster *mutable_test_as_Monster() {
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
}
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
}
void *mutable_test() {
return GetPointer<void *>(VT_TEST);
}
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *any_unique_as_M2() const {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
}
template<typename T> T *mutable_any_unique_as();
MyGame::Example::Monster *mutable_any_unique_as_M() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
}
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
}
void *mutable_any_unique() {
return GetPointer<void *>(VT_ANY_UNIQUE);
}
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
void *mutable_any_ambiguous() {
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
}
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
return test_as_Monster();
}
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
return mutable_test_as_Monster();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return test_as_TestSimpleTableWithEnum();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_test_as_TestSimpleTableWithEnum();
}
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
return test_as_MyGame_Example2_Monster();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
return mutable_test_as_MyGame_Example2_Monster();
}
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
return any_unique_as_M();
}
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
return mutable_any_unique_as_M();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return any_unique_as_TS();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_any_unique_as_TS();
}
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
return any_unique_as_M2();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
return mutable_any_unique_as_M2();
}
struct MonsterBuilder {
typedef Monster Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
}
template<typename T> T *mutable_test_as();
MyGame::Example::Monster *mutable_test_as_Monster() {
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
}
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
}
void *mutable_test() {
return GetPointer<void *>(VT_TEST);
}
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *any_unique_as_M2() const {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
}
template<typename T> T *mutable_any_unique_as();
MyGame::Example::Monster *mutable_any_unique_as_M() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
}
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
}
void *mutable_any_unique() {
return GetPointer<void *>(VT_ANY_UNIQUE);
}
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
void *mutable_any_ambiguous() {
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
}
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
return test_as_Monster();
}
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
return mutable_test_as_Monster();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return test_as_TestSimpleTableWithEnum();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_test_as_TestSimpleTableWithEnum();
}
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
return test_as_MyGame_Example2_Monster();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
return mutable_test_as_MyGame_Example2_Monster();
}
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
return any_unique_as_M();
}
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
return mutable_any_unique_as_M();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return any_unique_as_TS();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_any_unique_as_TS();
}
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
return any_unique_as_M2();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
return mutable_any_unique_as_M2();
}
struct MonsterBuilder {
typedef Monster Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
}
template<typename T> T *mutable_test_as();
MyGame::Example::Monster *mutable_test_as_Monster() {
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
}
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
}
void *mutable_test() {
return GetPointer<void *>(VT_TEST);
}
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example2::Monster *any_unique_as_M2() const {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
}
template<typename T> T *mutable_any_unique_as();
MyGame::Example::Monster *mutable_any_unique_as_M() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
}
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
}
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
}
void *mutable_any_unique() {
return GetPointer<void *>(VT_ANY_UNIQUE);
}
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
}
void *mutable_any_ambiguous() {
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
}
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
return test_as_Monster();
}
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
return mutable_test_as_Monster();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return test_as_TestSimpleTableWithEnum();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_test_as_TestSimpleTableWithEnum();
}
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
return test_as_MyGame_Example2_Monster();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
return mutable_test_as_MyGame_Example2_Monster();
}
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
return any_unique_as_M();
}
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
return mutable_any_unique_as_M();
}
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
return any_unique_as_TS();
}
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
return mutable_any_unique_as_TS();
}
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
return any_unique_as_M2();
}
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
return mutable_any_unique_as_M2();
}
struct MonsterBuilder {
typedef Monster Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -117,6 +117,10 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const NamespaceA::NamespaceB::TableInNestedNS *foo_union_as_TableInNestedNS() const {
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(foo_union()) : nullptr;
}
template<typename T> T *mutable_foo_union_as();
NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_union_as_TableInNestedNS() {
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<NamespaceA::NamespaceB::TableInNestedNS *>(mutable_foo_union()) : nullptr;
}
void *mutable_foo_union() {
return GetPointer<void *>(VT_FOO_UNION);
}
@@ -147,6 +151,10 @@ template<> inline const NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS:
return foo_union_as_TableInNestedNS();
}
template<> inline NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS::mutable_foo_union_as<NamespaceA::NamespaceB::TableInNestedNS>() {
return mutable_foo_union_as_TableInNestedNS();
}
struct TableInFirstNSBuilder {
typedef TableInFirstNS Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -420,6 +420,16 @@ struct D FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const UnionUnderlyingType::C *test_union_as_C() const {
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<const UnionUnderlyingType::C *>(test_union()) : nullptr;
}
template<typename T> T *mutable_test_union_as();
UnionUnderlyingType::A *mutable_test_union_as_A() {
return test_union_type() == UnionUnderlyingType::ABC::A ? static_cast<UnionUnderlyingType::A *>(mutable_test_union()) : nullptr;
}
UnionUnderlyingType::B *mutable_test_union_as_B() {
return test_union_type() == UnionUnderlyingType::ABC::B ? static_cast<UnionUnderlyingType::B *>(mutable_test_union()) : nullptr;
}
UnionUnderlyingType::C *mutable_test_union_as_C() {
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<UnionUnderlyingType::C *>(mutable_test_union()) : nullptr;
}
void *mutable_test_union() {
return GetPointer<void *>(VT_TEST_UNION);
}
@@ -457,14 +467,26 @@ template<> inline const UnionUnderlyingType::A *D::test_union_as<UnionUnderlying
return test_union_as_A();
}
template<> inline UnionUnderlyingType::A *D::mutable_test_union_as<UnionUnderlyingType::A>() {
return mutable_test_union_as_A();
}
template<> inline const UnionUnderlyingType::B *D::test_union_as<UnionUnderlyingType::B>() const {
return test_union_as_B();
}
template<> inline UnionUnderlyingType::B *D::mutable_test_union_as<UnionUnderlyingType::B>() {
return mutable_test_union_as_B();
}
template<> inline const UnionUnderlyingType::C *D::test_union_as<UnionUnderlyingType::C>() const {
return test_union_as_C();
}
template<> inline UnionUnderlyingType::C *D::mutable_test_union_as<UnionUnderlyingType::C>() {
return mutable_test_union_as_C();
}
struct DBuilder {
typedef D Table;
::flatbuffers::FlatBufferBuilder &fbb_;

View File

@@ -623,6 +623,24 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
const ::flatbuffers::String *main_character_as_Unused() const {
return main_character_type() == Character_Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
}
Attacker *mutable_main_character_as_MuLan() {
return main_character_type() == Character_MuLan ? static_cast<Attacker *>(mutable_main_character()) : nullptr;
}
Rapunzel *mutable_main_character_as_Rapunzel() {
return main_character_type() == Character_Rapunzel ? static_cast<Rapunzel *>(mutable_main_character()) : nullptr;
}
BookReader *mutable_main_character_as_Belle() {
return main_character_type() == Character_Belle ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
}
BookReader *mutable_main_character_as_BookFan() {
return main_character_type() == Character_BookFan ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
}
::flatbuffers::String *mutable_main_character_as_Other() {
return main_character_type() == Character_Other ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
}
::flatbuffers::String *mutable_main_character_as_Unused() {
return main_character_type() == Character_Unused ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
}
void *mutable_main_character() {
return GetPointer<void *>(VT_MAIN_CHARACTER);
}