Home | History | Annotate | Download | only in union_vector
      1 // automatically generated by the FlatBuffers compiler, do not modify
      2 
      3 
      4 #ifndef FLATBUFFERS_GENERATED_UNIONVECTOR_H_
      5 #define FLATBUFFERS_GENERATED_UNIONVECTOR_H_
      6 
      7 #include "flatbuffers/flatbuffers.h"
      8 
      9 struct Attacker;
     10 struct AttackerT;
     11 
     12 struct Rapunzel;
     13 
     14 struct BookReader;
     15 
     16 struct Movie;
     17 struct MovieT;
     18 
     19 bool operator==(const AttackerT &lhs, const AttackerT &rhs);
     20 bool operator==(const Rapunzel &lhs, const Rapunzel &rhs);
     21 bool operator==(const BookReader &lhs, const BookReader &rhs);
     22 bool operator==(const MovieT &lhs, const MovieT &rhs);
     23 
     24 inline const flatbuffers::TypeTable *AttackerTypeTable();
     25 
     26 inline const flatbuffers::TypeTable *RapunzelTypeTable();
     27 
     28 inline const flatbuffers::TypeTable *BookReaderTypeTable();
     29 
     30 inline const flatbuffers::TypeTable *MovieTypeTable();
     31 
     32 enum Character {
     33   Character_NONE = 0,
     34   Character_MuLan = 1,
     35   Character_Rapunzel = 2,
     36   Character_Belle = 3,
     37   Character_BookFan = 4,
     38   Character_Other = 5,
     39   Character_Unused = 6,
     40   Character_MIN = Character_NONE,
     41   Character_MAX = Character_Unused
     42 };
     43 
     44 inline const Character (&EnumValuesCharacter())[7] {
     45   static const Character values[] = {
     46     Character_NONE,
     47     Character_MuLan,
     48     Character_Rapunzel,
     49     Character_Belle,
     50     Character_BookFan,
     51     Character_Other,
     52     Character_Unused
     53   };
     54   return values;
     55 }
     56 
     57 inline const char * const *EnumNamesCharacter() {
     58   static const char * const names[] = {
     59     "NONE",
     60     "MuLan",
     61     "Rapunzel",
     62     "Belle",
     63     "BookFan",
     64     "Other",
     65     "Unused",
     66     nullptr
     67   };
     68   return names;
     69 }
     70 
     71 inline const char *EnumNameCharacter(Character e) {
     72   if (e < Character_NONE || e > Character_Unused) return "";
     73   const size_t index = static_cast<int>(e);
     74   return EnumNamesCharacter()[index];
     75 }
     76 
     77 struct CharacterUnion {
     78   Character type;
     79   void *value;
     80 
     81   CharacterUnion() : type(Character_NONE), value(nullptr) {}
     82   CharacterUnion(CharacterUnion&& u) FLATBUFFERS_NOEXCEPT :
     83     type(Character_NONE), value(nullptr)
     84     { std::swap(type, u.type); std::swap(value, u.value); }
     85   CharacterUnion(const CharacterUnion &) FLATBUFFERS_NOEXCEPT;
     86   CharacterUnion &operator=(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT
     87     { CharacterUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
     88   CharacterUnion &operator=(CharacterUnion &&u) FLATBUFFERS_NOEXCEPT
     89     { std::swap(type, u.type); std::swap(value, u.value); return *this; }
     90   ~CharacterUnion() { Reset(); }
     91 
     92   void Reset();
     93 
     94   static void *UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver);
     95   flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
     96 
     97   AttackerT *AsMuLan() {
     98     return type == Character_MuLan ?
     99       reinterpret_cast<AttackerT *>(value) : nullptr;
    100   }
    101   const AttackerT *AsMuLan() const {
    102     return type == Character_MuLan ?
    103       reinterpret_cast<const AttackerT *>(value) : nullptr;
    104   }
    105   Rapunzel *AsRapunzel() {
    106     return type == Character_Rapunzel ?
    107       reinterpret_cast<Rapunzel *>(value) : nullptr;
    108   }
    109   const Rapunzel *AsRapunzel() const {
    110     return type == Character_Rapunzel ?
    111       reinterpret_cast<const Rapunzel *>(value) : nullptr;
    112   }
    113   BookReader *AsBelle() {
    114     return type == Character_Belle ?
    115       reinterpret_cast<BookReader *>(value) : nullptr;
    116   }
    117   const BookReader *AsBelle() const {
    118     return type == Character_Belle ?
    119       reinterpret_cast<const BookReader *>(value) : nullptr;
    120   }
    121   BookReader *AsBookFan() {
    122     return type == Character_BookFan ?
    123       reinterpret_cast<BookReader *>(value) : nullptr;
    124   }
    125   const BookReader *AsBookFan() const {
    126     return type == Character_BookFan ?
    127       reinterpret_cast<const BookReader *>(value) : nullptr;
    128   }
    129   std::string *AsOther() {
    130     return type == Character_Other ?
    131       reinterpret_cast<std::string *>(value) : nullptr;
    132   }
    133   const std::string *AsOther() const {
    134     return type == Character_Other ?
    135       reinterpret_cast<const std::string *>(value) : nullptr;
    136   }
    137   std::string *AsUnused() {
    138     return type == Character_Unused ?
    139       reinterpret_cast<std::string *>(value) : nullptr;
    140   }
    141   const std::string *AsUnused() const {
    142     return type == Character_Unused ?
    143       reinterpret_cast<const std::string *>(value) : nullptr;
    144   }
    145 };
    146 
    147 
    148 inline bool operator==(const CharacterUnion &lhs, const CharacterUnion &rhs) {
    149   if (lhs.type != rhs.type) return false;
    150   switch (lhs.type) {
    151     case Character_NONE: {
    152       return true;
    153     }
    154     case Character_MuLan: {
    155       return *(reinterpret_cast<const AttackerT *>(lhs.value)) ==
    156              *(reinterpret_cast<const AttackerT *>(rhs.value));
    157     }
    158     case Character_Rapunzel: {
    159       return *(reinterpret_cast<const Rapunzel *>(lhs.value)) ==
    160              *(reinterpret_cast<const Rapunzel *>(rhs.value));
    161     }
    162     case Character_Belle: {
    163       return *(reinterpret_cast<const BookReader *>(lhs.value)) ==
    164              *(reinterpret_cast<const BookReader *>(rhs.value));
    165     }
    166     case Character_BookFan: {
    167       return *(reinterpret_cast<const BookReader *>(lhs.value)) ==
    168              *(reinterpret_cast<const BookReader *>(rhs.value));
    169     }
    170     case Character_Other: {
    171       return *(reinterpret_cast<const std::string *>(lhs.value)) ==
    172              *(reinterpret_cast<const std::string *>(rhs.value));
    173     }
    174     case Character_Unused: {
    175       return *(reinterpret_cast<const std::string *>(lhs.value)) ==
    176              *(reinterpret_cast<const std::string *>(rhs.value));
    177     }
    178     default: {
    179       return false;
    180     }
    181   }
    182 }
    183 bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type);
    184 bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
    185 
    186 FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Rapunzel FLATBUFFERS_FINAL_CLASS {
    187  private:
    188   int32_t hair_length_;
    189 
    190  public:
    191   Rapunzel() {
    192     memset(static_cast<void *>(this), 0, sizeof(Rapunzel));
    193   }
    194   Rapunzel(int32_t _hair_length)
    195       : hair_length_(flatbuffers::EndianScalar(_hair_length)) {
    196   }
    197   int32_t hair_length() const {
    198     return flatbuffers::EndianScalar(hair_length_);
    199   }
    200   void mutate_hair_length(int32_t _hair_length) {
    201     flatbuffers::WriteScalar(&hair_length_, _hair_length);
    202   }
    203 };
    204 FLATBUFFERS_STRUCT_END(Rapunzel, 4);
    205 
    206 inline bool operator==(const Rapunzel &lhs, const Rapunzel &rhs) {
    207   return
    208       (lhs.hair_length() == rhs.hair_length());
    209 }
    210 
    211 FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) BookReader FLATBUFFERS_FINAL_CLASS {
    212  private:
    213   int32_t books_read_;
    214 
    215  public:
    216   BookReader() {
    217     memset(static_cast<void *>(this), 0, sizeof(BookReader));
    218   }
    219   BookReader(int32_t _books_read)
    220       : books_read_(flatbuffers::EndianScalar(_books_read)) {
    221   }
    222   int32_t books_read() const {
    223     return flatbuffers::EndianScalar(books_read_);
    224   }
    225   void mutate_books_read(int32_t _books_read) {
    226     flatbuffers::WriteScalar(&books_read_, _books_read);
    227   }
    228 };
    229 FLATBUFFERS_STRUCT_END(BookReader, 4);
    230 
    231 inline bool operator==(const BookReader &lhs, const BookReader &rhs) {
    232   return
    233       (lhs.books_read() == rhs.books_read());
    234 }
    235 
    236 struct AttackerT : public flatbuffers::NativeTable {
    237   typedef Attacker TableType;
    238   int32_t sword_attack_damage;
    239   AttackerT()
    240       : sword_attack_damage(0) {
    241   }
    242 };
    243 
    244 inline bool operator==(const AttackerT &lhs, const AttackerT &rhs) {
    245   return
    246       (lhs.sword_attack_damage == rhs.sword_attack_damage);
    247 }
    248 
    249 struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
    250   typedef AttackerT NativeTableType;
    251   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
    252     return AttackerTypeTable();
    253   }
    254   enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
    255     VT_SWORD_ATTACK_DAMAGE = 4
    256   };
    257   int32_t sword_attack_damage() const {
    258     return GetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, 0);
    259   }
    260   bool mutate_sword_attack_damage(int32_t _sword_attack_damage) {
    261     return SetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, _sword_attack_damage, 0);
    262   }
    263   bool Verify(flatbuffers::Verifier &verifier) const {
    264     return VerifyTableStart(verifier) &&
    265            VerifyField<int32_t>(verifier, VT_SWORD_ATTACK_DAMAGE) &&
    266            verifier.EndTable();
    267   }
    268   AttackerT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
    269   void UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
    270   static flatbuffers::Offset<Attacker> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
    271 };
    272 
    273 struct AttackerBuilder {
    274   flatbuffers::FlatBufferBuilder &fbb_;
    275   flatbuffers::uoffset_t start_;
    276   void add_sword_attack_damage(int32_t sword_attack_damage) {
    277     fbb_.AddElement<int32_t>(Attacker::VT_SWORD_ATTACK_DAMAGE, sword_attack_damage, 0);
    278   }
    279   explicit AttackerBuilder(flatbuffers::FlatBufferBuilder &_fbb)
    280         : fbb_(_fbb) {
    281     start_ = fbb_.StartTable();
    282   }
    283   AttackerBuilder &operator=(const AttackerBuilder &);
    284   flatbuffers::Offset<Attacker> Finish() {
    285     const auto end = fbb_.EndTable(start_);
    286     auto o = flatbuffers::Offset<Attacker>(end);
    287     return o;
    288   }
    289 };
    290 
    291 inline flatbuffers::Offset<Attacker> CreateAttacker(
    292     flatbuffers::FlatBufferBuilder &_fbb,
    293     int32_t sword_attack_damage = 0) {
    294   AttackerBuilder builder_(_fbb);
    295   builder_.add_sword_attack_damage(sword_attack_damage);
    296   return builder_.Finish();
    297 }
    298 
    299 flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
    300 
    301 struct MovieT : public flatbuffers::NativeTable {
    302   typedef Movie TableType;
    303   CharacterUnion main_character;
    304   std::vector<CharacterUnion> characters;
    305   MovieT() {
    306   }
    307 };
    308 
    309 inline bool operator==(const MovieT &lhs, const MovieT &rhs) {
    310   return
    311       (lhs.main_character == rhs.main_character) &&
    312       (lhs.characters == rhs.characters);
    313 }
    314 
    315 struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
    316   typedef MovieT NativeTableType;
    317   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
    318     return MovieTypeTable();
    319   }
    320   enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
    321     VT_MAIN_CHARACTER_TYPE = 4,
    322     VT_MAIN_CHARACTER = 6,
    323     VT_CHARACTERS_TYPE = 8,
    324     VT_CHARACTERS = 10
    325   };
    326   Character main_character_type() const {
    327     return static_cast<Character>(GetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, 0));
    328   }
    329   bool mutate_main_character_type(Character _main_character_type) {
    330     return SetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(_main_character_type), 0);
    331   }
    332   const void *main_character() const {
    333     return GetPointer<const void *>(VT_MAIN_CHARACTER);
    334   }
    335   const Attacker *main_character_as_MuLan() const {
    336     return main_character_type() == Character_MuLan ? static_cast<const Attacker *>(main_character()) : nullptr;
    337   }
    338   const Rapunzel *main_character_as_Rapunzel() const {
    339     return main_character_type() == Character_Rapunzel ? static_cast<const Rapunzel *>(main_character()) : nullptr;
    340   }
    341   const BookReader *main_character_as_Belle() const {
    342     return main_character_type() == Character_Belle ? static_cast<const BookReader *>(main_character()) : nullptr;
    343   }
    344   const BookReader *main_character_as_BookFan() const {
    345     return main_character_type() == Character_BookFan ? static_cast<const BookReader *>(main_character()) : nullptr;
    346   }
    347   const flatbuffers::String *main_character_as_Other() const {
    348     return main_character_type() == Character_Other ? static_cast<const flatbuffers::String *>(main_character()) : nullptr;
    349   }
    350   const flatbuffers::String *main_character_as_Unused() const {
    351     return main_character_type() == Character_Unused ? static_cast<const flatbuffers::String *>(main_character()) : nullptr;
    352   }
    353   void *mutable_main_character() {
    354     return GetPointer<void *>(VT_MAIN_CHARACTER);
    355   }
    356   const flatbuffers::Vector<uint8_t> *characters_type() const {
    357     return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
    358   }
    359   flatbuffers::Vector<uint8_t> *mutable_characters_type() {
    360     return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
    361   }
    362   const flatbuffers::Vector<flatbuffers::Offset<void>> *characters() const {
    363     return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS);
    364   }
    365   flatbuffers::Vector<flatbuffers::Offset<void>> *mutable_characters() {
    366     return GetPointer<flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS);
    367   }
    368   bool Verify(flatbuffers::Verifier &verifier) const {
    369     return VerifyTableStart(verifier) &&
    370            VerifyField<uint8_t>(verifier, VT_MAIN_CHARACTER_TYPE) &&
    371            VerifyOffset(verifier, VT_MAIN_CHARACTER) &&
    372            VerifyCharacter(verifier, main_character(), main_character_type()) &&
    373            VerifyOffset(verifier, VT_CHARACTERS_TYPE) &&
    374            verifier.VerifyVector(characters_type()) &&
    375            VerifyOffset(verifier, VT_CHARACTERS) &&
    376            verifier.VerifyVector(characters()) &&
    377            VerifyCharacterVector(verifier, characters(), characters_type()) &&
    378            verifier.EndTable();
    379   }
    380   MovieT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
    381   void UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
    382   static flatbuffers::Offset<Movie> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
    383 };
    384 
    385 struct MovieBuilder {
    386   flatbuffers::FlatBufferBuilder &fbb_;
    387   flatbuffers::uoffset_t start_;
    388   void add_main_character_type(Character main_character_type) {
    389     fbb_.AddElement<uint8_t>(Movie::VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(main_character_type), 0);
    390   }
    391   void add_main_character(flatbuffers::Offset<void> main_character) {
    392     fbb_.AddOffset(Movie::VT_MAIN_CHARACTER, main_character);
    393   }
    394   void add_characters_type(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type) {
    395     fbb_.AddOffset(Movie::VT_CHARACTERS_TYPE, characters_type);
    396   }
    397   void add_characters(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters) {
    398     fbb_.AddOffset(Movie::VT_CHARACTERS, characters);
    399   }
    400   explicit MovieBuilder(flatbuffers::FlatBufferBuilder &_fbb)
    401         : fbb_(_fbb) {
    402     start_ = fbb_.StartTable();
    403   }
    404   MovieBuilder &operator=(const MovieBuilder &);
    405   flatbuffers::Offset<Movie> Finish() {
    406     const auto end = fbb_.EndTable(start_);
    407     auto o = flatbuffers::Offset<Movie>(end);
    408     return o;
    409   }
    410 };
    411 
    412 inline flatbuffers::Offset<Movie> CreateMovie(
    413     flatbuffers::FlatBufferBuilder &_fbb,
    414     Character main_character_type = Character_NONE,
    415     flatbuffers::Offset<void> main_character = 0,
    416     flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type = 0,
    417     flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters = 0) {
    418   MovieBuilder builder_(_fbb);
    419   builder_.add_characters(characters);
    420   builder_.add_characters_type(characters_type);
    421   builder_.add_main_character(main_character);
    422   builder_.add_main_character_type(main_character_type);
    423   return builder_.Finish();
    424 }
    425 
    426 inline flatbuffers::Offset<Movie> CreateMovieDirect(
    427     flatbuffers::FlatBufferBuilder &_fbb,
    428     Character main_character_type = Character_NONE,
    429     flatbuffers::Offset<void> main_character = 0,
    430     const std::vector<uint8_t> *characters_type = nullptr,
    431     const std::vector<flatbuffers::Offset<void>> *characters = nullptr) {
    432   auto characters_type__ = characters_type ? _fbb.CreateVector<uint8_t>(*characters_type) : 0;
    433   auto characters__ = characters ? _fbb.CreateVector<flatbuffers::Offset<void>>(*characters) : 0;
    434   return CreateMovie(
    435       _fbb,
    436       main_character_type,
    437       main_character,
    438       characters_type__,
    439       characters__);
    440 }
    441 
    442 flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
    443 
    444 inline AttackerT *Attacker::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
    445   auto _o = new AttackerT();
    446   UnPackTo(_o, _resolver);
    447   return _o;
    448 }
    449 
    450 inline void Attacker::UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver) const {
    451   (void)_o;
    452   (void)_resolver;
    453   { auto _e = sword_attack_damage(); _o->sword_attack_damage = _e; };
    454 }
    455 
    456 inline flatbuffers::Offset<Attacker> Attacker::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
    457   return CreateAttacker(_fbb, _o, _rehasher);
    458 }
    459 
    460 inline flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
    461   (void)_rehasher;
    462   (void)_o;
    463   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AttackerT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
    464   auto _sword_attack_damage = _o->sword_attack_damage;
    465   return CreateAttacker(
    466       _fbb,
    467       _sword_attack_damage);
    468 }
    469 
    470 inline MovieT *Movie::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
    471   auto _o = new MovieT();
    472   UnPackTo(_o, _resolver);
    473   return _o;
    474 }
    475 
    476 inline void Movie::UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver) const {
    477   (void)_o;
    478   (void)_resolver;
    479   { auto _e = main_character_type(); _o->main_character.type = _e; };
    480   { auto _e = main_character(); if (_e) _o->main_character.value = CharacterUnion::UnPack(_e, main_character_type(), _resolver); };
    481   { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = static_cast<Character>(_e->Get(_i)); } } };
    482   { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } };
    483 }
    484 
    485 inline flatbuffers::Offset<Movie> Movie::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
    486   return CreateMovie(_fbb, _o, _rehasher);
    487 }
    488 
    489 inline flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
    490   (void)_rehasher;
    491   (void)_o;
    492   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MovieT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
    493   auto _main_character_type = _o->main_character.type;
    494   auto _main_character = _o->main_character.Pack(_fbb);
    495   auto _characters_type = _o->characters.size() ? _fbb.CreateVector<uint8_t>(_o->characters.size(), [](size_t i, _VectorArgs *__va) { return static_cast<uint8_t>(__va->__o->characters[i].type); }, &_va) : 0;
    496   auto _characters = _o->characters.size() ? _fbb.CreateVector<flatbuffers::Offset<void>>(_o->characters.size(), [](size_t i, _VectorArgs *__va) { return __va->__o->characters[i].Pack(*__va->__fbb, __va->__rehasher); }, &_va) : 0;
    497   return CreateMovie(
    498       _fbb,
    499       _main_character_type,
    500       _main_character,
    501       _characters_type,
    502       _characters);
    503 }
    504 
    505 inline bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type) {
    506   switch (type) {
    507     case Character_NONE: {
    508       return true;
    509     }
    510     case Character_MuLan: {
    511       auto ptr = reinterpret_cast<const Attacker *>(obj);
    512       return verifier.VerifyTable(ptr);
    513     }
    514     case Character_Rapunzel: {
    515       return true;
    516     }
    517     case Character_Belle: {
    518       return true;
    519     }
    520     case Character_BookFan: {
    521       return true;
    522     }
    523     case Character_Other: {
    524       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
    525       return verifier.VerifyString(ptr);
    526     }
    527     case Character_Unused: {
    528       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
    529       return verifier.VerifyString(ptr);
    530     }
    531     default: return false;
    532   }
    533 }
    534 
    535 inline bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
    536   if (!values || !types) return !values && !types;
    537   if (values->size() != types->size()) return false;
    538   for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
    539     if (!VerifyCharacter(
    540         verifier,  values->Get(i), types->GetEnum<Character>(i))) {
    541       return false;
    542     }
    543   }
    544   return true;
    545 }
    546 
    547 inline void *CharacterUnion::UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver) {
    548   switch (type) {
    549     case Character_MuLan: {
    550       auto ptr = reinterpret_cast<const Attacker *>(obj);
    551       return ptr->UnPack(resolver);
    552     }
    553     case Character_Rapunzel: {
    554       auto ptr = reinterpret_cast<const Rapunzel *>(obj);
    555       return new Rapunzel(*ptr);
    556     }
    557     case Character_Belle: {
    558       auto ptr = reinterpret_cast<const BookReader *>(obj);
    559       return new BookReader(*ptr);
    560     }
    561     case Character_BookFan: {
    562       auto ptr = reinterpret_cast<const BookReader *>(obj);
    563       return new BookReader(*ptr);
    564     }
    565     case Character_Other: {
    566       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
    567       return new std::string(ptr->c_str(), ptr->size());
    568     }
    569     case Character_Unused: {
    570       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
    571       return new std::string(ptr->c_str(), ptr->size());
    572     }
    573     default: return nullptr;
    574   }
    575 }
    576 
    577 inline flatbuffers::Offset<void> CharacterUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
    578   switch (type) {
    579     case Character_MuLan: {
    580       auto ptr = reinterpret_cast<const AttackerT *>(value);
    581       return CreateAttacker(_fbb, ptr, _rehasher).Union();
    582     }
    583     case Character_Rapunzel: {
    584       auto ptr = reinterpret_cast<const Rapunzel *>(value);
    585       return _fbb.CreateStruct(*ptr).Union();
    586     }
    587     case Character_Belle: {
    588       auto ptr = reinterpret_cast<const BookReader *>(value);
    589       return _fbb.CreateStruct(*ptr).Union();
    590     }
    591     case Character_BookFan: {
    592       auto ptr = reinterpret_cast<const BookReader *>(value);
    593       return _fbb.CreateStruct(*ptr).Union();
    594     }
    595     case Character_Other: {
    596       auto ptr = reinterpret_cast<const std::string *>(value);
    597       return _fbb.CreateString(*ptr).Union();
    598     }
    599     case Character_Unused: {
    600       auto ptr = reinterpret_cast<const std::string *>(value);
    601       return _fbb.CreateString(*ptr).Union();
    602     }
    603     default: return 0;
    604   }
    605 }
    606 
    607 inline CharacterUnion::CharacterUnion(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) {
    608   switch (type) {
    609     case Character_MuLan: {
    610       value = new AttackerT(*reinterpret_cast<AttackerT *>(u.value));
    611       break;
    612     }
    613     case Character_Rapunzel: {
    614       value = new Rapunzel(*reinterpret_cast<Rapunzel *>(u.value));
    615       break;
    616     }
    617     case Character_Belle: {
    618       value = new BookReader(*reinterpret_cast<BookReader *>(u.value));
    619       break;
    620     }
    621     case Character_BookFan: {
    622       value = new BookReader(*reinterpret_cast<BookReader *>(u.value));
    623       break;
    624     }
    625     case Character_Other: {
    626       value = new std::string(*reinterpret_cast<std::string *>(u.value));
    627       break;
    628     }
    629     case Character_Unused: {
    630       value = new std::string(*reinterpret_cast<std::string *>(u.value));
    631       break;
    632     }
    633     default:
    634       break;
    635   }
    636 }
    637 
    638 inline void CharacterUnion::Reset() {
    639   switch (type) {
    640     case Character_MuLan: {
    641       auto ptr = reinterpret_cast<AttackerT *>(value);
    642       delete ptr;
    643       break;
    644     }
    645     case Character_Rapunzel: {
    646       auto ptr = reinterpret_cast<Rapunzel *>(value);
    647       delete ptr;
    648       break;
    649     }
    650     case Character_Belle: {
    651       auto ptr = reinterpret_cast<BookReader *>(value);
    652       delete ptr;
    653       break;
    654     }
    655     case Character_BookFan: {
    656       auto ptr = reinterpret_cast<BookReader *>(value);
    657       delete ptr;
    658       break;
    659     }
    660     case Character_Other: {
    661       auto ptr = reinterpret_cast<std::string *>(value);
    662       delete ptr;
    663       break;
    664     }
    665     case Character_Unused: {
    666       auto ptr = reinterpret_cast<std::string *>(value);
    667       delete ptr;
    668       break;
    669     }
    670     default: break;
    671   }
    672   value = nullptr;
    673   type = Character_NONE;
    674 }
    675 
    676 inline const flatbuffers::TypeTable *CharacterTypeTable() {
    677   static const flatbuffers::TypeCode type_codes[] = {
    678     { flatbuffers::ET_SEQUENCE, 0, -1 },
    679     { flatbuffers::ET_SEQUENCE, 0, 0 },
    680     { flatbuffers::ET_SEQUENCE, 0, 1 },
    681     { flatbuffers::ET_SEQUENCE, 0, 2 },
    682     { flatbuffers::ET_SEQUENCE, 0, 2 },
    683     { flatbuffers::ET_STRING, 0, -1 },
    684     { flatbuffers::ET_STRING, 0, -1 }
    685   };
    686   static const flatbuffers::TypeFunction type_refs[] = {
    687     AttackerTypeTable,
    688     RapunzelTypeTable,
    689     BookReaderTypeTable
    690   };
    691   static const char * const names[] = {
    692     "NONE",
    693     "MuLan",
    694     "Rapunzel",
    695     "Belle",
    696     "BookFan",
    697     "Other",
    698     "Unused"
    699   };
    700   static const flatbuffers::TypeTable tt = {
    701     flatbuffers::ST_UNION, 7, type_codes, type_refs, nullptr, names
    702   };
    703   return &tt;
    704 }
    705 
    706 inline const flatbuffers::TypeTable *AttackerTypeTable() {
    707   static const flatbuffers::TypeCode type_codes[] = {
    708     { flatbuffers::ET_INT, 0, -1 }
    709   };
    710   static const char * const names[] = {
    711     "sword_attack_damage"
    712   };
    713   static const flatbuffers::TypeTable tt = {
    714     flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names
    715   };
    716   return &tt;
    717 }
    718 
    719 inline const flatbuffers::TypeTable *RapunzelTypeTable() {
    720   static const flatbuffers::TypeCode type_codes[] = {
    721     { flatbuffers::ET_INT, 0, -1 }
    722   };
    723   static const int64_t values[] = { 0, 4 };
    724   static const char * const names[] = {
    725     "hair_length"
    726   };
    727   static const flatbuffers::TypeTable tt = {
    728     flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
    729   };
    730   return &tt;
    731 }
    732 
    733 inline const flatbuffers::TypeTable *BookReaderTypeTable() {
    734   static const flatbuffers::TypeCode type_codes[] = {
    735     { flatbuffers::ET_INT, 0, -1 }
    736   };
    737   static const int64_t values[] = { 0, 4 };
    738   static const char * const names[] = {
    739     "books_read"
    740   };
    741   static const flatbuffers::TypeTable tt = {
    742     flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
    743   };
    744   return &tt;
    745 }
    746 
    747 inline const flatbuffers::TypeTable *MovieTypeTable() {
    748   static const flatbuffers::TypeCode type_codes[] = {
    749     { flatbuffers::ET_UTYPE, 0, 0 },
    750     { flatbuffers::ET_SEQUENCE, 0, 0 },
    751     { flatbuffers::ET_UTYPE, 1, 0 },
    752     { flatbuffers::ET_SEQUENCE, 1, 0 }
    753   };
    754   static const flatbuffers::TypeFunction type_refs[] = {
    755     CharacterTypeTable
    756   };
    757   static const char * const names[] = {
    758     "main_character_type",
    759     "main_character",
    760     "characters_type",
    761     "characters"
    762   };
    763   static const flatbuffers::TypeTable tt = {
    764     flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, names
    765   };
    766   return &tt;
    767 }
    768 
    769 inline const Movie *GetMovie(const void *buf) {
    770   return flatbuffers::GetRoot<Movie>(buf);
    771 }
    772 
    773 inline const Movie *GetSizePrefixedMovie(const void *buf) {
    774   return flatbuffers::GetSizePrefixedRoot<Movie>(buf);
    775 }
    776 
    777 inline Movie *GetMutableMovie(void *buf) {
    778   return flatbuffers::GetMutableRoot<Movie>(buf);
    779 }
    780 
    781 inline const char *MovieIdentifier() {
    782   return "MOVI";
    783 }
    784 
    785 inline bool MovieBufferHasIdentifier(const void *buf) {
    786   return flatbuffers::BufferHasIdentifier(
    787       buf, MovieIdentifier());
    788 }
    789 
    790 inline bool VerifyMovieBuffer(
    791     flatbuffers::Verifier &verifier) {
    792   return verifier.VerifyBuffer<Movie>(MovieIdentifier());
    793 }
    794 
    795 inline bool VerifySizePrefixedMovieBuffer(
    796     flatbuffers::Verifier &verifier) {
    797   return verifier.VerifySizePrefixedBuffer<Movie>(MovieIdentifier());
    798 }
    799 
    800 inline void FinishMovieBuffer(
    801     flatbuffers::FlatBufferBuilder &fbb,
    802     flatbuffers::Offset<Movie> root) {
    803   fbb.Finish(root, MovieIdentifier());
    804 }
    805 
    806 inline void FinishSizePrefixedMovieBuffer(
    807     flatbuffers::FlatBufferBuilder &fbb,
    808     flatbuffers::Offset<Movie> root) {
    809   fbb.FinishSizePrefixed(root, MovieIdentifier());
    810 }
    811 
    812 inline flatbuffers::unique_ptr<MovieT> UnPackMovie(
    813     const void *buf,
    814     const flatbuffers::resolver_function_t *res = nullptr) {
    815   return flatbuffers::unique_ptr<MovieT>(GetMovie(buf)->UnPack(res));
    816 }
    817 
    818 #endif  // FLATBUFFERS_GENERATED_UNIONVECTOR_H_
    819