• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 enum Character {
20   Character_NONE = 0,
21   Character_MuLan = 1,
22   Character_Rapunzel = 2,
23   Character_Belle = 3,
24   Character_BookFan = 4,
25   Character_Other = 5,
26   Character_Unused = 6,
27   Character_MIN = Character_NONE,
28   Character_MAX = Character_Unused
29 };
30 
EnumValuesCharacter()31 inline Character (&EnumValuesCharacter())[7] {
32   static Character values[] = {
33     Character_NONE,
34     Character_MuLan,
35     Character_Rapunzel,
36     Character_Belle,
37     Character_BookFan,
38     Character_Other,
39     Character_Unused
40   };
41   return values;
42 }
43 
EnumNamesCharacter()44 inline const char **EnumNamesCharacter() {
45   static const char *names[] = {
46     "NONE",
47     "MuLan",
48     "Rapunzel",
49     "Belle",
50     "BookFan",
51     "Other",
52     "Unused",
53     nullptr
54   };
55   return names;
56 }
57 
EnumNameCharacter(Character e)58 inline const char *EnumNameCharacter(Character e) {
59   const size_t index = static_cast<int>(e);
60   return EnumNamesCharacter()[index];
61 }
62 
63 struct CharacterUnion {
64   Character type;
65   void *value;
66 
CharacterUnionCharacterUnion67   CharacterUnion() : type(Character_NONE), value(nullptr) {}
CharacterUnionCharacterUnion68   CharacterUnion(CharacterUnion&& u) FLATBUFFERS_NOEXCEPT :
69     type(Character_NONE), value(nullptr)
70     { std::swap(type, u.type); std::swap(value, u.value); }
71   CharacterUnion(const CharacterUnion &) FLATBUFFERS_NOEXCEPT;
72   CharacterUnion &operator=(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT
73     { CharacterUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
74   CharacterUnion &operator=(CharacterUnion &&u) FLATBUFFERS_NOEXCEPT
75     { std::swap(type, u.type); std::swap(value, u.value); return *this; }
~CharacterUnionCharacterUnion76   ~CharacterUnion() { Reset(); }
77 
78   void Reset();
79 
80   static void *UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver);
81   flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
82 
AsMuLanCharacterUnion83   AttackerT *AsMuLan() {
84     return type == Character_MuLan ?
85       reinterpret_cast<AttackerT *>(value) : nullptr;
86   }
AsMuLanCharacterUnion87   const AttackerT *AsMuLan() const {
88     return type == Character_MuLan ?
89       reinterpret_cast<const AttackerT *>(value) : nullptr;
90   }
AsRapunzelCharacterUnion91   Rapunzel *AsRapunzel() {
92     return type == Character_Rapunzel ?
93       reinterpret_cast<Rapunzel *>(value) : nullptr;
94   }
AsRapunzelCharacterUnion95   const Rapunzel *AsRapunzel() const {
96     return type == Character_Rapunzel ?
97       reinterpret_cast<const Rapunzel *>(value) : nullptr;
98   }
AsBelleCharacterUnion99   BookReader *AsBelle() {
100     return type == Character_Belle ?
101       reinterpret_cast<BookReader *>(value) : nullptr;
102   }
AsBelleCharacterUnion103   const BookReader *AsBelle() const {
104     return type == Character_Belle ?
105       reinterpret_cast<const BookReader *>(value) : nullptr;
106   }
AsBookFanCharacterUnion107   BookReader *AsBookFan() {
108     return type == Character_BookFan ?
109       reinterpret_cast<BookReader *>(value) : nullptr;
110   }
AsBookFanCharacterUnion111   const BookReader *AsBookFan() const {
112     return type == Character_BookFan ?
113       reinterpret_cast<const BookReader *>(value) : nullptr;
114   }
AsOtherCharacterUnion115   std::string *AsOther() {
116     return type == Character_Other ?
117       reinterpret_cast<std::string *>(value) : nullptr;
118   }
AsOtherCharacterUnion119   const std::string *AsOther() const {
120     return type == Character_Other ?
121       reinterpret_cast<const std::string *>(value) : nullptr;
122   }
AsUnusedCharacterUnion123   std::string *AsUnused() {
124     return type == Character_Unused ?
125       reinterpret_cast<std::string *>(value) : nullptr;
126   }
AsUnusedCharacterUnion127   const std::string *AsUnused() const {
128     return type == Character_Unused ?
129       reinterpret_cast<const std::string *>(value) : nullptr;
130   }
131 };
132 
133 bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type);
134 bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
135 
136 MANUALLY_ALIGNED_STRUCT(4) Rapunzel FLATBUFFERS_FINAL_CLASS {
137  private:
138   int32_t hair_length_;
139 
140  public:
Rapunzel()141   Rapunzel() {
142     memset(this, 0, sizeof(Rapunzel));
143   }
Rapunzel(int32_t _hair_length)144   Rapunzel(int32_t _hair_length)
145       : hair_length_(flatbuffers::EndianScalar(_hair_length)) {
146   }
hair_length()147   int32_t hair_length() const {
148     return flatbuffers::EndianScalar(hair_length_);
149   }
mutate_hair_length(int32_t _hair_length)150   void mutate_hair_length(int32_t _hair_length) {
151     flatbuffers::WriteScalar(&hair_length_, _hair_length);
152   }
153 };
154 STRUCT_END(Rapunzel, 4);
155 
156 MANUALLY_ALIGNED_STRUCT(4) BookReader FLATBUFFERS_FINAL_CLASS {
157  private:
158   int32_t books_read_;
159 
160  public:
BookReader()161   BookReader() {
162     memset(this, 0, sizeof(BookReader));
163   }
BookReader(int32_t _books_read)164   BookReader(int32_t _books_read)
165       : books_read_(flatbuffers::EndianScalar(_books_read)) {
166   }
books_read()167   int32_t books_read() const {
168     return flatbuffers::EndianScalar(books_read_);
169   }
mutate_books_read(int32_t _books_read)170   void mutate_books_read(int32_t _books_read) {
171     flatbuffers::WriteScalar(&books_read_, _books_read);
172   }
173 };
174 STRUCT_END(BookReader, 4);
175 
176 struct AttackerT : public flatbuffers::NativeTable {
177   typedef Attacker TableType;
178   int32_t sword_attack_damage;
AttackerTAttackerT179   AttackerT()
180       : sword_attack_damage(0) {
181   }
182 };
183 
184 struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
185   typedef AttackerT NativeTableType;
186   enum {
187     VT_SWORD_ATTACK_DAMAGE = 4
188   };
sword_attack_damageFLATBUFFERS_FINAL_CLASS189   int32_t sword_attack_damage() const {
190     return GetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, 0);
191   }
mutate_sword_attack_damageFLATBUFFERS_FINAL_CLASS192   bool mutate_sword_attack_damage(int32_t _sword_attack_damage) {
193     return SetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, _sword_attack_damage, 0);
194   }
VerifyFLATBUFFERS_FINAL_CLASS195   bool Verify(flatbuffers::Verifier &verifier) const {
196     return VerifyTableStart(verifier) &&
197            VerifyField<int32_t>(verifier, VT_SWORD_ATTACK_DAMAGE) &&
198            verifier.EndTable();
199   }
200   AttackerT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
201   void UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
202   static flatbuffers::Offset<Attacker> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
203 };
204 
205 struct AttackerBuilder {
206   flatbuffers::FlatBufferBuilder &fbb_;
207   flatbuffers::uoffset_t start_;
add_sword_attack_damageAttackerBuilder208   void add_sword_attack_damage(int32_t sword_attack_damage) {
209     fbb_.AddElement<int32_t>(Attacker::VT_SWORD_ATTACK_DAMAGE, sword_attack_damage, 0);
210   }
AttackerBuilderAttackerBuilder211   explicit AttackerBuilder(flatbuffers::FlatBufferBuilder &_fbb)
212         : fbb_(_fbb) {
213     start_ = fbb_.StartTable();
214   }
215   AttackerBuilder &operator=(const AttackerBuilder &);
FinishAttackerBuilder216   flatbuffers::Offset<Attacker> Finish() {
217     const auto end = fbb_.EndTable(start_);
218     auto o = flatbuffers::Offset<Attacker>(end);
219     return o;
220   }
221 };
222 
223 inline flatbuffers::Offset<Attacker> CreateAttacker(
224     flatbuffers::FlatBufferBuilder &_fbb,
225     int32_t sword_attack_damage = 0) {
226   AttackerBuilder builder_(_fbb);
227   builder_.add_sword_attack_damage(sword_attack_damage);
228   return builder_.Finish();
229 }
230 
231 flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
232 
233 struct MovieT : public flatbuffers::NativeTable {
234   typedef Movie TableType;
235   CharacterUnion main_character;
236   std::vector<CharacterUnion> characters;
MovieTMovieT237   MovieT() {
238   }
239 };
240 
241 struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
242   typedef MovieT NativeTableType;
243   enum {
244     VT_MAIN_CHARACTER_TYPE = 4,
245     VT_MAIN_CHARACTER = 6,
246     VT_CHARACTERS_TYPE = 8,
247     VT_CHARACTERS = 10
248   };
main_character_typeFLATBUFFERS_FINAL_CLASS249   Character main_character_type() const {
250     return static_cast<Character>(GetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, 0));
251   }
mutate_main_character_typeFLATBUFFERS_FINAL_CLASS252   bool mutate_main_character_type(Character _main_character_type) {
253     return SetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(_main_character_type), 0);
254   }
main_characterFLATBUFFERS_FINAL_CLASS255   const void *main_character() const {
256     return GetPointer<const void *>(VT_MAIN_CHARACTER);
257   }
258   template<typename T> const T *main_character_as() const;
main_character_as_MuLanFLATBUFFERS_FINAL_CLASS259   const Attacker *main_character_as_MuLan() const {
260     return main_character_type() == Character_MuLan ? static_cast<const Attacker *>(main_character()) : nullptr;
261   }
main_character_as_RapunzelFLATBUFFERS_FINAL_CLASS262   const Rapunzel *main_character_as_Rapunzel() const {
263     return main_character_type() == Character_Rapunzel ? static_cast<const Rapunzel *>(main_character()) : nullptr;
264   }
main_character_as_BelleFLATBUFFERS_FINAL_CLASS265   const BookReader *main_character_as_Belle() const {
266     return main_character_type() == Character_Belle ? static_cast<const BookReader *>(main_character()) : nullptr;
267   }
main_character_as_BookFanFLATBUFFERS_FINAL_CLASS268   const BookReader *main_character_as_BookFan() const {
269     return main_character_type() == Character_BookFan ? static_cast<const BookReader *>(main_character()) : nullptr;
270   }
main_character_as_OtherFLATBUFFERS_FINAL_CLASS271   const flatbuffers::String *main_character_as_Other() const {
272     return main_character_type() == Character_Other ? static_cast<const flatbuffers::String *>(main_character()) : nullptr;
273   }
main_character_as_UnusedFLATBUFFERS_FINAL_CLASS274   const flatbuffers::String *main_character_as_Unused() const {
275     return main_character_type() == Character_Unused ? static_cast<const flatbuffers::String *>(main_character()) : nullptr;
276   }
mutable_main_characterFLATBUFFERS_FINAL_CLASS277   void *mutable_main_character() {
278     return GetPointer<void *>(VT_MAIN_CHARACTER);
279   }
characters_typeFLATBUFFERS_FINAL_CLASS280   const flatbuffers::Vector<uint8_t> *characters_type() const {
281     return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
282   }
mutable_characters_typeFLATBUFFERS_FINAL_CLASS283   flatbuffers::Vector<uint8_t> *mutable_characters_type() {
284     return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
285   }
charactersFLATBUFFERS_FINAL_CLASS286   const flatbuffers::Vector<flatbuffers::Offset<void>> *characters() const {
287     return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS);
288   }
mutable_charactersFLATBUFFERS_FINAL_CLASS289   flatbuffers::Vector<flatbuffers::Offset<void>> *mutable_characters() {
290     return GetPointer<flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS);
291   }
VerifyFLATBUFFERS_FINAL_CLASS292   bool Verify(flatbuffers::Verifier &verifier) const {
293     return VerifyTableStart(verifier) &&
294            VerifyField<uint8_t>(verifier, VT_MAIN_CHARACTER_TYPE) &&
295            VerifyOffset(verifier, VT_MAIN_CHARACTER) &&
296            VerifyCharacter(verifier, main_character(), main_character_type()) &&
297            VerifyOffset(verifier, VT_CHARACTERS_TYPE) &&
298            verifier.Verify(characters_type()) &&
299            VerifyOffset(verifier, VT_CHARACTERS) &&
300            verifier.Verify(characters()) &&
301            VerifyCharacterVector(verifier, characters(), characters_type()) &&
302            verifier.EndTable();
303   }
304   MovieT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
305   void UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
306   static flatbuffers::Offset<Movie> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
307 };
308 
309 struct MovieBuilder {
310   flatbuffers::FlatBufferBuilder &fbb_;
311   flatbuffers::uoffset_t start_;
add_main_character_typeMovieBuilder312   void add_main_character_type(Character main_character_type) {
313     fbb_.AddElement<uint8_t>(Movie::VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(main_character_type), 0);
314   }
add_main_characterMovieBuilder315   void add_main_character(flatbuffers::Offset<void> main_character) {
316     fbb_.AddOffset(Movie::VT_MAIN_CHARACTER, main_character);
317   }
add_characters_typeMovieBuilder318   void add_characters_type(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type) {
319     fbb_.AddOffset(Movie::VT_CHARACTERS_TYPE, characters_type);
320   }
add_charactersMovieBuilder321   void add_characters(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters) {
322     fbb_.AddOffset(Movie::VT_CHARACTERS, characters);
323   }
MovieBuilderMovieBuilder324   explicit MovieBuilder(flatbuffers::FlatBufferBuilder &_fbb)
325         : fbb_(_fbb) {
326     start_ = fbb_.StartTable();
327   }
328   MovieBuilder &operator=(const MovieBuilder &);
FinishMovieBuilder329   flatbuffers::Offset<Movie> Finish() {
330     const auto end = fbb_.EndTable(start_);
331     auto o = flatbuffers::Offset<Movie>(end);
332     return o;
333   }
334 };
335 
336 inline flatbuffers::Offset<Movie> CreateMovie(
337     flatbuffers::FlatBufferBuilder &_fbb,
338     Character main_character_type = Character_NONE,
339     flatbuffers::Offset<void> main_character = 0,
340     flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type = 0,
341     flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters = 0) {
342   MovieBuilder builder_(_fbb);
343   builder_.add_characters(characters);
344   builder_.add_characters_type(characters_type);
345   builder_.add_main_character(main_character);
346   builder_.add_main_character_type(main_character_type);
347   return builder_.Finish();
348 }
349 
350 inline flatbuffers::Offset<Movie> CreateMovieDirect(
351     flatbuffers::FlatBufferBuilder &_fbb,
352     Character main_character_type = Character_NONE,
353     flatbuffers::Offset<void> main_character = 0,
354     const std::vector<uint8_t> *characters_type = nullptr,
355     const std::vector<flatbuffers::Offset<void>> *characters = nullptr) {
356   return CreateMovie(
357       _fbb,
358       main_character_type,
359       main_character,
360       characters_type ? _fbb.CreateVector<uint8_t>(*characters_type) : 0,
361       characters ? _fbb.CreateVector<flatbuffers::Offset<void>>(*characters) : 0);
362 }
363 
364 flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
365 
UnPack(const flatbuffers::resolver_function_t * _resolver)366 inline AttackerT *Attacker::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
367   auto _o = new AttackerT();
368   UnPackTo(_o, _resolver);
369   return _o;
370 }
371 
UnPackTo(AttackerT * _o,const flatbuffers::resolver_function_t * _resolver)372 inline void Attacker::UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver) const {
373   (void)_o;
374   (void)_resolver;
375   { auto _e = sword_attack_damage(); _o->sword_attack_damage = _e; };
376 }
377 
Pack(flatbuffers::FlatBufferBuilder & _fbb,const AttackerT * _o,const flatbuffers::rehasher_function_t * _rehasher)378 inline flatbuffers::Offset<Attacker> Attacker::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
379   return CreateAttacker(_fbb, _o, _rehasher);
380 }
381 
CreateAttacker(flatbuffers::FlatBufferBuilder & _fbb,const AttackerT * _o,const flatbuffers::rehasher_function_t * _rehasher)382 inline flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
383   (void)_rehasher;
384   (void)_o;
385   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AttackerT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
386   auto _sword_attack_damage = _o->sword_attack_damage;
387   return CreateAttacker(
388       _fbb,
389       _sword_attack_damage);
390 }
391 
UnPack(const flatbuffers::resolver_function_t * _resolver)392 inline MovieT *Movie::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
393   auto _o = new MovieT();
394   UnPackTo(_o, _resolver);
395   return _o;
396 }
397 
UnPackTo(MovieT * _o,const flatbuffers::resolver_function_t * _resolver)398 inline void Movie::UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver) const {
399   (void)_o;
400   (void)_resolver;
401   { auto _e = main_character_type(); _o->main_character.type = _e; };
402   { auto _e = main_character(); if (_e) _o->main_character.value = CharacterUnion::UnPack(_e, main_character_type(), _resolver); };
403   { 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 = (Character)_e->Get(_i); } } };
404   { 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); } } };
405 }
406 
Pack(flatbuffers::FlatBufferBuilder & _fbb,const MovieT * _o,const flatbuffers::rehasher_function_t * _rehasher)407 inline flatbuffers::Offset<Movie> Movie::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
408   return CreateMovie(_fbb, _o, _rehasher);
409 }
410 
CreateMovie(flatbuffers::FlatBufferBuilder & _fbb,const MovieT * _o,const flatbuffers::rehasher_function_t * _rehasher)411 inline flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
412   (void)_rehasher;
413   (void)_o;
414   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MovieT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
415   auto _main_character_type = _o->main_character.type;
416   auto _main_character = _o->main_character.Pack(_fbb);
417   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;
418   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;
419   return CreateMovie(
420       _fbb,
421       _main_character_type,
422       _main_character,
423       _characters_type,
424       _characters);
425 }
426 
VerifyCharacter(flatbuffers::Verifier & verifier,const void * obj,Character type)427 inline bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type) {
428   switch (type) {
429     case Character_NONE: {
430       return true;
431     }
432     case Character_MuLan: {
433       auto ptr = reinterpret_cast<const Attacker *>(obj);
434       return verifier.VerifyTable(ptr);
435     }
436     case Character_Rapunzel: {
437       return true;
438     }
439     case Character_Belle: {
440       return true;
441     }
442     case Character_BookFan: {
443       return true;
444     }
445     case Character_Other: {
446       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
447       return verifier.Verify(ptr);
448     }
449     case Character_Unused: {
450       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
451       return verifier.Verify(ptr);
452     }
453     default: return false;
454   }
455 }
456 
VerifyCharacterVector(flatbuffers::Verifier & verifier,const flatbuffers::Vector<flatbuffers::Offset<void>> * values,const flatbuffers::Vector<uint8_t> * types)457 inline bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
458   if (values->size() != types->size()) return false;
459   for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
460     if (!VerifyCharacter(
461         verifier,  values->Get(i), types->GetEnum<Character>(i))) {
462       return false;
463     }
464   }
465   return true;
466 }
467 
UnPack(const void * obj,Character type,const flatbuffers::resolver_function_t * resolver)468 inline void *CharacterUnion::UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver) {
469   switch (type) {
470     case Character_MuLan: {
471       auto ptr = reinterpret_cast<const Attacker *>(obj);
472       return ptr->UnPack(resolver);
473     }
474     case Character_Rapunzel: {
475       auto ptr = reinterpret_cast<const Rapunzel *>(obj);
476       return new Rapunzel(*ptr);
477     }
478     case Character_Belle: {
479       auto ptr = reinterpret_cast<const BookReader *>(obj);
480       return new BookReader(*ptr);
481     }
482     case Character_BookFan: {
483       auto ptr = reinterpret_cast<const BookReader *>(obj);
484       return new BookReader(*ptr);
485     }
486     case Character_Other: {
487       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
488       return new std::string(ptr->c_str(), ptr->size());
489     }
490     case Character_Unused: {
491       auto ptr = reinterpret_cast<const flatbuffers::String *>(obj);
492       return new std::string(ptr->c_str(), ptr->size());
493     }
494     default: return nullptr;
495   }
496 }
497 
Pack(flatbuffers::FlatBufferBuilder & _fbb,const flatbuffers::rehasher_function_t * _rehasher)498 inline flatbuffers::Offset<void> CharacterUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
499   switch (type) {
500     case Character_MuLan: {
501       auto ptr = reinterpret_cast<const AttackerT *>(value);
502       return CreateAttacker(_fbb, ptr, _rehasher).Union();
503     }
504     case Character_Rapunzel: {
505       auto ptr = reinterpret_cast<const Rapunzel *>(value);
506       return _fbb.CreateStruct(*ptr).Union();
507     }
508     case Character_Belle: {
509       auto ptr = reinterpret_cast<const BookReader *>(value);
510       return _fbb.CreateStruct(*ptr).Union();
511     }
512     case Character_BookFan: {
513       auto ptr = reinterpret_cast<const BookReader *>(value);
514       return _fbb.CreateStruct(*ptr).Union();
515     }
516     case Character_Other: {
517       auto ptr = reinterpret_cast<const std::string *>(value);
518       return _fbb.CreateString(*ptr).Union();
519     }
520     case Character_Unused: {
521       auto ptr = reinterpret_cast<const std::string *>(value);
522       return _fbb.CreateString(*ptr).Union();
523     }
524     default: return 0;
525   }
526 }
527 
CharacterUnion(const CharacterUnion & u)528 inline CharacterUnion::CharacterUnion(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) {
529   switch (type) {
530     case Character_MuLan: {
531       value = new AttackerT(*reinterpret_cast<AttackerT *>(u.value));
532       break;
533     }
534     case Character_Rapunzel: {
535       value = new Rapunzel(*reinterpret_cast<Rapunzel *>(u.value));
536       break;
537     }
538     case Character_Belle: {
539       value = new BookReader(*reinterpret_cast<BookReader *>(u.value));
540       break;
541     }
542     case Character_BookFan: {
543       value = new BookReader(*reinterpret_cast<BookReader *>(u.value));
544       break;
545     }
546     case Character_Other: {
547       value = new std::string(*reinterpret_cast<std::string *>(u.value));
548       break;
549     }
550     case Character_Unused: {
551       value = new std::string(*reinterpret_cast<std::string *>(u.value));
552       break;
553     }
554     default:
555       break;
556   }
557 }
558 
Reset()559 inline void CharacterUnion::Reset() {
560   switch (type) {
561     case Character_MuLan: {
562       auto ptr = reinterpret_cast<AttackerT *>(value);
563       delete ptr;
564       break;
565     }
566     case Character_Rapunzel: {
567       auto ptr = reinterpret_cast<Rapunzel *>(value);
568       delete ptr;
569       break;
570     }
571     case Character_Belle: {
572       auto ptr = reinterpret_cast<BookReader *>(value);
573       delete ptr;
574       break;
575     }
576     case Character_BookFan: {
577       auto ptr = reinterpret_cast<BookReader *>(value);
578       delete ptr;
579       break;
580     }
581     case Character_Other: {
582       auto ptr = reinterpret_cast<std::string *>(value);
583       delete ptr;
584       break;
585     }
586     case Character_Unused: {
587       auto ptr = reinterpret_cast<std::string *>(value);
588       delete ptr;
589       break;
590     }
591     default: break;
592   }
593   value = nullptr;
594   type = Character_NONE;
595 }
596 
597 inline flatbuffers::TypeTable *AttackerTypeTable();
598 
599 inline flatbuffers::TypeTable *RapunzelTypeTable();
600 
601 inline flatbuffers::TypeTable *BookReaderTypeTable();
602 
603 inline flatbuffers::TypeTable *MovieTypeTable();
604 
CharacterTypeTable()605 inline flatbuffers::TypeTable *CharacterTypeTable() {
606   static flatbuffers::TypeCode type_codes[] = {
607     { flatbuffers::ET_SEQUENCE, 0, -1 },
608     { flatbuffers::ET_SEQUENCE, 0, 0 },
609     { flatbuffers::ET_SEQUENCE, 0, 1 },
610     { flatbuffers::ET_SEQUENCE, 0, 2 },
611     { flatbuffers::ET_SEQUENCE, 0, 2 },
612     { flatbuffers::ET_STRING, 0, -1 },
613     { flatbuffers::ET_STRING, 0, -1 }
614   };
615   static flatbuffers::TypeFunction type_refs[] = {
616     AttackerTypeTable,
617     RapunzelTypeTable,
618     BookReaderTypeTable
619   };
620   static const char *names[] = {
621     "NONE",
622     "MuLan",
623     "Rapunzel",
624     "Belle",
625     "BookFan",
626     "Other",
627     "Unused"
628   };
629   static flatbuffers::TypeTable tt = {
630     flatbuffers::ST_UNION, 7, type_codes, type_refs, nullptr, names
631   };
632   return &tt;
633 }
634 
AttackerTypeTable()635 inline flatbuffers::TypeTable *AttackerTypeTable() {
636   static flatbuffers::TypeCode type_codes[] = {
637     { flatbuffers::ET_INT, 0, -1 }
638   };
639   static const char *names[] = {
640     "sword_attack_damage"
641   };
642   static flatbuffers::TypeTable tt = {
643     flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names
644   };
645   return &tt;
646 }
647 
RapunzelTypeTable()648 inline flatbuffers::TypeTable *RapunzelTypeTable() {
649   static flatbuffers::TypeCode type_codes[] = {
650     { flatbuffers::ET_INT, 0, -1 }
651   };
652   static const int32_t values[] = { 0, 4 };
653   static const char *names[] = {
654     "hair_length"
655   };
656   static flatbuffers::TypeTable tt = {
657     flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
658   };
659   return &tt;
660 }
661 
BookReaderTypeTable()662 inline flatbuffers::TypeTable *BookReaderTypeTable() {
663   static flatbuffers::TypeCode type_codes[] = {
664     { flatbuffers::ET_INT, 0, -1 }
665   };
666   static const int32_t values[] = { 0, 4 };
667   static const char *names[] = {
668     "books_read"
669   };
670   static flatbuffers::TypeTable tt = {
671     flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
672   };
673   return &tt;
674 }
675 
MovieTypeTable()676 inline flatbuffers::TypeTable *MovieTypeTable() {
677   static flatbuffers::TypeCode type_codes[] = {
678     { flatbuffers::ET_UTYPE, 0, 0 },
679     { flatbuffers::ET_SEQUENCE, 0, 0 },
680     { flatbuffers::ET_UTYPE, 1, 0 },
681     { flatbuffers::ET_SEQUENCE, 1, 0 }
682   };
683   static flatbuffers::TypeFunction type_refs[] = {
684     CharacterTypeTable
685   };
686   static const char *names[] = {
687     "main_character_type",
688     "main_character",
689     "characters_type",
690     "characters"
691   };
692   static flatbuffers::TypeTable tt = {
693     flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, names
694   };
695   return &tt;
696 }
697 
GetMovie(const void * buf)698 inline const Movie *GetMovie(const void *buf) {
699   return flatbuffers::GetRoot<Movie>(buf);
700 }
701 
GetMutableMovie(void * buf)702 inline Movie *GetMutableMovie(void *buf) {
703   return flatbuffers::GetMutableRoot<Movie>(buf);
704 }
705 
MovieIdentifier()706 inline const char *MovieIdentifier() {
707   return "MOVI";
708 }
709 
MovieBufferHasIdentifier(const void * buf)710 inline bool MovieBufferHasIdentifier(const void *buf) {
711   return flatbuffers::BufferHasIdentifier(
712       buf, MovieIdentifier());
713 }
714 
VerifyMovieBuffer(flatbuffers::Verifier & verifier)715 inline bool VerifyMovieBuffer(
716     flatbuffers::Verifier &verifier) {
717   return verifier.VerifyBuffer<Movie>(MovieIdentifier());
718 }
719 
FinishMovieBuffer(flatbuffers::FlatBufferBuilder & fbb,flatbuffers::Offset<Movie> root)720 inline void FinishMovieBuffer(
721     flatbuffers::FlatBufferBuilder &fbb,
722     flatbuffers::Offset<Movie> root) {
723   fbb.Finish(root, MovieIdentifier());
724 }
725 
726 inline flatbuffers::unique_ptr<MovieT> UnPackMovie(
727     const void *buf,
728     const flatbuffers::resolver_function_t *res = nullptr) {
729   return flatbuffers::unique_ptr<MovieT>(GetMovie(buf)->UnPack(res));
730 }
731 
732 #endif  // FLATBUFFERS_GENERATED_UNIONVECTOR_H_
733