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