mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 20:15:34 +00:00
generate mutable union accessors
This commit is contained in:
@@ -1484,6 +1484,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_test() {
|
||||
return GetPointer<void *>(VT_TEST);
|
||||
}
|
||||
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;
|
||||
}
|
||||
const ::flatbuffers::Vector<const MyGame::Example::Test *> *test4() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
|
||||
}
|
||||
@@ -1719,6 +1729,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_any_unique() {
|
||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||
}
|
||||
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;
|
||||
}
|
||||
MyGame::Example::AnyAmbiguousAliases any_ambiguous_type() const {
|
||||
return static_cast<MyGame::Example::AnyAmbiguousAliases>(GetField<uint8_t>(VT_ANY_AMBIGUOUS_TYPE, 0));
|
||||
}
|
||||
@@ -1737,6 +1757,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_any_ambiguous() {
|
||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||
}
|
||||
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;
|
||||
}
|
||||
const ::flatbuffers::Vector<MyGame::Example::Color> *vector_of_enums() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<MyGame::Example::Color> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
@@ -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_;
|
||||
|
||||
@@ -598,6 +598,24 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_main_character() {
|
||||
return GetPointer<void *>(VT_MAIN_CHARACTER);
|
||||
}
|
||||
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;
|
||||
}
|
||||
const ::flatbuffers::Vector<Character> *characters_type() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<Character> *>(VT_CHARACTERS_TYPE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user