mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-17 01:26:45 +00:00
generate mutable union accessors
This commit is contained in:
@@ -327,6 +327,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_equipped() {
|
||||
return GetPointer<void *>(VT_EQUIPPED);
|
||||
}
|
||||
template<typename T> T *mutable_equipped_as();
|
||||
MyGame::Sample::Weapon *mutable_equipped_as_Weapon() {
|
||||
return equipped_type() == MyGame::Sample::Equipment_Weapon ? static_cast<MyGame::Sample::Weapon *>(mutable_equipped()) : nullptr;
|
||||
}
|
||||
const ::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *path() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *>(VT_PATH);
|
||||
}
|
||||
@@ -363,6 +367,10 @@ template<> inline const MyGame::Sample::Weapon *Monster::equipped_as<MyGame::Sam
|
||||
return equipped_as_Weapon();
|
||||
}
|
||||
|
||||
template<> inline MyGame::Sample::Weapon *Monster::mutable_equipped_as<MyGame::Sample::Weapon>() {
|
||||
return mutable_equipped_as_Weapon();
|
||||
}
|
||||
|
||||
struct MonsterBuilder {
|
||||
typedef Monster Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
|
||||
@@ -2625,14 +2625,18 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += " }";
|
||||
}
|
||||
|
||||
void GenTableUnionAsGetters(const FieldDef& field) {
|
||||
void GenTableUnionAsGetters(const FieldDef& field, bool is_mutable) {
|
||||
const auto& type = field.value.type;
|
||||
auto u = type.enum_def;
|
||||
|
||||
code_.SetValue("MUTABLE_EXT", is_mutable ? "" : " const");
|
||||
code_.SetValue("MUTABLE", is_mutable ? "mutable_" : "");
|
||||
|
||||
if (!type.enum_def->uses_multiple_type_instances)
|
||||
code_ +=
|
||||
" template<typename T> "
|
||||
"const T *{{NULLABLE_EXT}}{{FIELD_NAME}}_as() const;";
|
||||
" template<typename T>"
|
||||
"{{MUTABLE_EXT}} T *{{MUTABLE}}{{NULLABLE_EXT}}{{FIELD_NAME}}_as()"
|
||||
"{{MUTABLE_EXT}};";
|
||||
|
||||
for (auto u_it = u->Vals().begin(); u_it != u->Vals().end(); ++u_it) {
|
||||
auto& ev = **u_it;
|
||||
@@ -2646,15 +2650,19 @@ class CppGenerator : public BaseGenerator {
|
||||
EscapeKeyword(Name(field) + UnionTypeFieldSuffix()));
|
||||
code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace(u->defined_namespace,
|
||||
GetEnumValUse(*u, ev)));
|
||||
code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *");
|
||||
code_.SetValue("U_FIELD_TYPE",
|
||||
(is_mutable ? "" : "const ") + full_struct_name + " *");
|
||||
code_.SetValue("U_FIELD_NAME", Name(field) + "_as_" + Name(ev));
|
||||
code_.SetValue("U_NULLABLE", NullableExtension());
|
||||
|
||||
// `const Type *union_name_asType() const` accessor.
|
||||
code_ += " {{U_FIELD_TYPE}}{{U_NULLABLE}}{{U_FIELD_NAME}}() const {";
|
||||
// and `Type *mutable_union_name_asType()` accessor.
|
||||
code_ +=
|
||||
" {{U_FIELD_TYPE}}{{U_NULLABLE}}{{MUTABLE}}{{U_FIELD_NAME}}()"
|
||||
"{{MUTABLE_EXT}} {";
|
||||
code_ +=
|
||||
" return {{U_GET_TYPE}}() == {{U_ELEMENT_TYPE}} ? "
|
||||
"static_cast<{{U_FIELD_TYPE}}>({{FIELD_NAME}}()) "
|
||||
"static_cast<{{U_FIELD_TYPE}}>({{MUTABLE}}{{FIELD_NAME}}()) "
|
||||
": nullptr;";
|
||||
code_ += " }";
|
||||
}
|
||||
@@ -2709,7 +2717,7 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
if (type.base_type == BASE_TYPE_UNION) {
|
||||
GenTableUnionAsGetters(field);
|
||||
GenTableUnionAsGetters(field, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2898,6 +2906,11 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += " {{FIELD_TYPE}}mutable_{{FIELD_NAME}}() {";
|
||||
code_ += " return {{FIELD_VALUE}};";
|
||||
code_ += " }";
|
||||
|
||||
// mutable union accessors
|
||||
if (type.base_type == BASE_TYPE_UNION) {
|
||||
GenTableUnionAsGetters(field, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3074,6 +3087,7 @@ class CppGenerator : public BaseGenerator {
|
||||
code_.SetValue("U_FIELD_NAME", Name(*field) + "_as_" + Name(ev));
|
||||
|
||||
// `template<> const T *union_name_as<T>() const` accessor.
|
||||
// and `template<> T *mutable_union_name_as<T>()` accessor.
|
||||
code_ +=
|
||||
"template<> "
|
||||
"inline {{U_FIELD_TYPE}}{{STRUCT_NAME}}::{{FIELD_NAME}}_as"
|
||||
@@ -3081,6 +3095,20 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += " return {{U_FIELD_NAME}}();";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
|
||||
if (opts_.mutable_buffer) {
|
||||
code_.SetValue("U_FIELD_TYPE", full_struct_name + " *");
|
||||
code_.SetValue("U_FIELD_NAME",
|
||||
"mutable_" + Name(*field) + "_as_" + Name(ev));
|
||||
code_ +=
|
||||
"template<> "
|
||||
"inline {{U_FIELD_TYPE}}"
|
||||
"{{STRUCT_NAME}}::mutable_{{FIELD_NAME}}_as"
|
||||
"<{{U_ELEMENT_NAME}}>() {";
|
||||
code_ += " return {{U_FIELD_NAME}}();";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1480,6 +1480,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);
|
||||
}
|
||||
@@ -1715,6 +1725,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));
|
||||
}
|
||||
@@ -1733,6 +1753,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<uint8_t> *vector_of_enums() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
@@ -1939,26 +1968,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_;
|
||||
|
||||
@@ -1471,6 +1471,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);
|
||||
}
|
||||
@@ -1706,6 +1716,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));
|
||||
}
|
||||
@@ -1724,6 +1744,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<uint8_t> *vector_of_enums() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
@@ -1930,26 +1959,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_;
|
||||
|
||||
@@ -1471,6 +1471,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);
|
||||
}
|
||||
@@ -1706,6 +1716,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));
|
||||
}
|
||||
@@ -1724,6 +1744,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<uint8_t> *vector_of_enums() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
@@ -1930,26 +1959,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_;
|
||||
|
||||
@@ -1471,6 +1471,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);
|
||||
}
|
||||
@@ -1706,6 +1716,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));
|
||||
}
|
||||
@@ -1724,6 +1744,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<uint8_t> *vector_of_enums() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
@@ -1930,26 +1959,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_;
|
||||
|
||||
@@ -120,6 +120,10 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
void *mutable_foo_union() {
|
||||
return GetPointer<void *>(VT_FOO_UNION);
|
||||
}
|
||||
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;
|
||||
}
|
||||
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const {
|
||||
return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
|
||||
}
|
||||
@@ -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_;
|
||||
|
||||
@@ -614,6 +614,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<uint8_t> *characters_type() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user