generate mutable union accessors

This commit is contained in:
Justin Davis
2025-12-09 21:51:53 -05:00
parent 89430a14d6
commit c7627432ef
10 changed files with 352 additions and 7 deletions

View File

@@ -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_;