• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 
4 #ifndef FLATBUFFERS_GENERATED_MONSTER_MYGAME_SAMPLE_H_
5 #define FLATBUFFERS_GENERATED_MONSTER_MYGAME_SAMPLE_H_
6 
7 #include "flatbuffers/flatbuffers.h"
8 
9 namespace MyGame {
10 namespace Sample {
11 
12 struct Vec3;
13 
14 struct Monster;
15 struct MonsterT;
16 
17 struct Weapon;
18 struct WeaponT;
19 
20 bool operator==(const Vec3 &lhs, const Vec3 &rhs);
21 bool operator==(const MonsterT &lhs, const MonsterT &rhs);
22 bool operator==(const WeaponT &lhs, const WeaponT &rhs);
23 
24 inline const flatbuffers::TypeTable *Vec3TypeTable();
25 
26 inline const flatbuffers::TypeTable *MonsterTypeTable();
27 
28 inline const flatbuffers::TypeTable *WeaponTypeTable();
29 
30 enum Color {
31   Color_Red = 0,
32   Color_Green = 1,
33   Color_Blue = 2,
34   Color_MIN = Color_Red,
35   Color_MAX = Color_Blue
36 };
37 
EnumValuesColor()38 inline const Color (&EnumValuesColor())[3] {
39   static const Color values[] = {
40     Color_Red,
41     Color_Green,
42     Color_Blue
43   };
44   return values;
45 }
46 
EnumNamesColor()47 inline const char * const *EnumNamesColor() {
48   static const char * const names[] = {
49     "Red",
50     "Green",
51     "Blue",
52     nullptr
53   };
54   return names;
55 }
56 
EnumNameColor(Color e)57 inline const char *EnumNameColor(Color e) {
58   if (e < Color_Red || e > Color_Blue) return "";
59   const size_t index = static_cast<int>(e);
60   return EnumNamesColor()[index];
61 }
62 
63 enum Equipment {
64   Equipment_NONE = 0,
65   Equipment_Weapon = 1,
66   Equipment_MIN = Equipment_NONE,
67   Equipment_MAX = Equipment_Weapon
68 };
69 
EnumValuesEquipment()70 inline const Equipment (&EnumValuesEquipment())[2] {
71   static const Equipment values[] = {
72     Equipment_NONE,
73     Equipment_Weapon
74   };
75   return values;
76 }
77 
EnumNamesEquipment()78 inline const char * const *EnumNamesEquipment() {
79   static const char * const names[] = {
80     "NONE",
81     "Weapon",
82     nullptr
83   };
84   return names;
85 }
86 
EnumNameEquipment(Equipment e)87 inline const char *EnumNameEquipment(Equipment e) {
88   if (e < Equipment_NONE || e > Equipment_Weapon) return "";
89   const size_t index = static_cast<int>(e);
90   return EnumNamesEquipment()[index];
91 }
92 
93 template<typename T> struct EquipmentTraits {
94   static const Equipment enum_value = Equipment_NONE;
95 };
96 
97 template<> struct EquipmentTraits<Weapon> {
98   static const Equipment enum_value = Equipment_Weapon;
99 };
100 
101 struct EquipmentUnion {
102   Equipment type;
103   void *value;
104 
105   EquipmentUnion() : type(Equipment_NONE), value(nullptr) {}
106   EquipmentUnion(EquipmentUnion&& u) FLATBUFFERS_NOEXCEPT :
107     type(Equipment_NONE), value(nullptr)
108     { std::swap(type, u.type); std::swap(value, u.value); }
109   EquipmentUnion(const EquipmentUnion &) FLATBUFFERS_NOEXCEPT;
110   EquipmentUnion &operator=(const EquipmentUnion &u) FLATBUFFERS_NOEXCEPT
111     { EquipmentUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
112   EquipmentUnion &operator=(EquipmentUnion &&u) FLATBUFFERS_NOEXCEPT
113     { std::swap(type, u.type); std::swap(value, u.value); return *this; }
114   ~EquipmentUnion() { Reset(); }
115 
116   void Reset();
117 
118 #ifndef FLATBUFFERS_CPP98_STL
119   template <typename T>
120   void Set(T&& val) {
121     Reset();
122     type = EquipmentTraits<typename T::TableType>::enum_value;
123     if (type != Equipment_NONE) {
124       value = new T(std::forward<T>(val));
125     }
126   }
127 #endif  // FLATBUFFERS_CPP98_STL
128 
129   static void *UnPack(const void *obj, Equipment type, const flatbuffers::resolver_function_t *resolver);
130   flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
131 
132   WeaponT *AsWeapon() {
133     return type == Equipment_Weapon ?
134       reinterpret_cast<WeaponT *>(value) : nullptr;
135   }
136   const WeaponT *AsWeapon() const {
137     return type == Equipment_Weapon ?
138       reinterpret_cast<const WeaponT *>(value) : nullptr;
139   }
140 };
141 
142 
143 inline bool operator==(const EquipmentUnion &lhs, const EquipmentUnion &rhs) {
144   if (lhs.type != rhs.type) return false;
145   switch (lhs.type) {
146     case Equipment_NONE: {
147       return true;
148     }
149     case Equipment_Weapon: {
150       return *(reinterpret_cast<const WeaponT *>(lhs.value)) ==
151              *(reinterpret_cast<const WeaponT *>(rhs.value));
152     }
153     default: {
154       return false;
155     }
156   }
157 }
158 bool VerifyEquipment(flatbuffers::Verifier &verifier, const void *obj, Equipment type);
159 bool VerifyEquipmentVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
160 
161 FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
162  private:
163   float x_;
164   float y_;
165   float z_;
166 
167  public:
168   Vec3() {
169     memset(static_cast<void *>(this), 0, sizeof(Vec3));
170   }
171   Vec3(float _x, float _y, float _z)
172       : x_(flatbuffers::EndianScalar(_x)),
173         y_(flatbuffers::EndianScalar(_y)),
174         z_(flatbuffers::EndianScalar(_z)) {
175   }
176   float x() const {
177     return flatbuffers::EndianScalar(x_);
178   }
179   void mutate_x(float _x) {
180     flatbuffers::WriteScalar(&x_, _x);
181   }
182   float y() const {
183     return flatbuffers::EndianScalar(y_);
184   }
185   void mutate_y(float _y) {
186     flatbuffers::WriteScalar(&y_, _y);
187   }
188   float z() const {
189     return flatbuffers::EndianScalar(z_);
190   }
191   void mutate_z(float _z) {
192     flatbuffers::WriteScalar(&z_, _z);
193   }
194 };
195 FLATBUFFERS_STRUCT_END(Vec3, 12);
196 
197 inline bool operator==(const Vec3 &lhs, const Vec3 &rhs) {
198   return
199       (lhs.x() == rhs.x()) &&
200       (lhs.y() == rhs.y()) &&
201       (lhs.z() == rhs.z());
202 }
203 
204 struct MonsterT : public flatbuffers::NativeTable {
205   typedef Monster TableType;
206   flatbuffers::unique_ptr<Vec3> pos;
207   int16_t mana;
208   int16_t hp;
209   std::string name;
210   std::vector<uint8_t> inventory;
211   Color color;
212   std::vector<flatbuffers::unique_ptr<WeaponT>> weapons;
213   EquipmentUnion equipped;
214   MonsterT()
215       : mana(150),
216         hp(100),
217         color(Color_Blue) {
218   }
219 };
220 
221 inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) {
222   return
223       (lhs.pos == rhs.pos) &&
224       (lhs.mana == rhs.mana) &&
225       (lhs.hp == rhs.hp) &&
226       (lhs.name == rhs.name) &&
227       (lhs.inventory == rhs.inventory) &&
228       (lhs.color == rhs.color) &&
229       (lhs.weapons == rhs.weapons) &&
230       (lhs.equipped == rhs.equipped);
231 }
232 
233 struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
234   typedef MonsterT NativeTableType;
235   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
236     return MonsterTypeTable();
237   }
238   enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
239     VT_POS = 4,
240     VT_MANA = 6,
241     VT_HP = 8,
242     VT_NAME = 10,
243     VT_INVENTORY = 14,
244     VT_COLOR = 16,
245     VT_WEAPONS = 18,
246     VT_EQUIPPED_TYPE = 20,
247     VT_EQUIPPED = 22
248   };
249   const Vec3 *pos() const {
250     return GetStruct<const Vec3 *>(VT_POS);
251   }
252   Vec3 *mutable_pos() {
253     return GetStruct<Vec3 *>(VT_POS);
254   }
255   int16_t mana() const {
256     return GetField<int16_t>(VT_MANA, 150);
257   }
258   bool mutate_mana(int16_t _mana) {
259     return SetField<int16_t>(VT_MANA, _mana, 150);
260   }
261   int16_t hp() const {
262     return GetField<int16_t>(VT_HP, 100);
263   }
264   bool mutate_hp(int16_t _hp) {
265     return SetField<int16_t>(VT_HP, _hp, 100);
266   }
267   const flatbuffers::String *name() const {
268     return GetPointer<const flatbuffers::String *>(VT_NAME);
269   }
270   flatbuffers::String *mutable_name() {
271     return GetPointer<flatbuffers::String *>(VT_NAME);
272   }
273   const flatbuffers::Vector<uint8_t> *inventory() const {
274     return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
275   }
276   flatbuffers::Vector<uint8_t> *mutable_inventory() {
277     return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
278   }
279   Color color() const {
280     return static_cast<Color>(GetField<int8_t>(VT_COLOR, 2));
281   }
282   bool mutate_color(Color _color) {
283     return SetField<int8_t>(VT_COLOR, static_cast<int8_t>(_color), 2);
284   }
285   const flatbuffers::Vector<flatbuffers::Offset<Weapon>> *weapons() const {
286     return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Weapon>> *>(VT_WEAPONS);
287   }
288   flatbuffers::Vector<flatbuffers::Offset<Weapon>> *mutable_weapons() {
289     return GetPointer<flatbuffers::Vector<flatbuffers::Offset<Weapon>> *>(VT_WEAPONS);
290   }
291   Equipment equipped_type() const {
292     return static_cast<Equipment>(GetField<uint8_t>(VT_EQUIPPED_TYPE, 0));
293   }
294   bool mutate_equipped_type(Equipment _equipped_type) {
295     return SetField<uint8_t>(VT_EQUIPPED_TYPE, static_cast<uint8_t>(_equipped_type), 0);
296   }
297   const void *equipped() const {
298     return GetPointer<const void *>(VT_EQUIPPED);
299   }
300   template<typename T> const T *equipped_as() const;
301   const Weapon *equipped_as_Weapon() const {
302     return equipped_type() == Equipment_Weapon ? static_cast<const Weapon *>(equipped()) : nullptr;
303   }
304   void *mutable_equipped() {
305     return GetPointer<void *>(VT_EQUIPPED);
306   }
307   bool Verify(flatbuffers::Verifier &verifier) const {
308     return VerifyTableStart(verifier) &&
309            VerifyField<Vec3>(verifier, VT_POS) &&
310            VerifyField<int16_t>(verifier, VT_MANA) &&
311            VerifyField<int16_t>(verifier, VT_HP) &&
312            VerifyOffset(verifier, VT_NAME) &&
313            verifier.VerifyString(name()) &&
314            VerifyOffset(verifier, VT_INVENTORY) &&
315            verifier.VerifyVector(inventory()) &&
316            VerifyField<int8_t>(verifier, VT_COLOR) &&
317            VerifyOffset(verifier, VT_WEAPONS) &&
318            verifier.VerifyVector(weapons()) &&
319            verifier.VerifyVectorOfTables(weapons()) &&
320            VerifyField<uint8_t>(verifier, VT_EQUIPPED_TYPE) &&
321            VerifyOffset(verifier, VT_EQUIPPED) &&
322            VerifyEquipment(verifier, equipped(), equipped_type()) &&
323            verifier.EndTable();
324   }
325   MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
326   void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
327   static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
328 };
329 
330 template<> inline const Weapon *Monster::equipped_as<Weapon>() const {
331   return equipped_as_Weapon();
332 }
333 
334 struct MonsterBuilder {
335   flatbuffers::FlatBufferBuilder &fbb_;
336   flatbuffers::uoffset_t start_;
337   void add_pos(const Vec3 *pos) {
338     fbb_.AddStruct(Monster::VT_POS, pos);
339   }
340   void add_mana(int16_t mana) {
341     fbb_.AddElement<int16_t>(Monster::VT_MANA, mana, 150);
342   }
343   void add_hp(int16_t hp) {
344     fbb_.AddElement<int16_t>(Monster::VT_HP, hp, 100);
345   }
346   void add_name(flatbuffers::Offset<flatbuffers::String> name) {
347     fbb_.AddOffset(Monster::VT_NAME, name);
348   }
349   void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) {
350     fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
351   }
352   void add_color(Color color) {
353     fbb_.AddElement<int8_t>(Monster::VT_COLOR, static_cast<int8_t>(color), 2);
354   }
355   void add_weapons(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Weapon>>> weapons) {
356     fbb_.AddOffset(Monster::VT_WEAPONS, weapons);
357   }
358   void add_equipped_type(Equipment equipped_type) {
359     fbb_.AddElement<uint8_t>(Monster::VT_EQUIPPED_TYPE, static_cast<uint8_t>(equipped_type), 0);
360   }
361   void add_equipped(flatbuffers::Offset<void> equipped) {
362     fbb_.AddOffset(Monster::VT_EQUIPPED, equipped);
363   }
364   explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
365         : fbb_(_fbb) {
366     start_ = fbb_.StartTable();
367   }
368   MonsterBuilder &operator=(const MonsterBuilder &);
369   flatbuffers::Offset<Monster> Finish() {
370     const auto end = fbb_.EndTable(start_);
371     auto o = flatbuffers::Offset<Monster>(end);
372     return o;
373   }
374 };
375 
376 inline flatbuffers::Offset<Monster> CreateMonster(
377     flatbuffers::FlatBufferBuilder &_fbb,
378     const Vec3 *pos = 0,
379     int16_t mana = 150,
380     int16_t hp = 100,
381     flatbuffers::Offset<flatbuffers::String> name = 0,
382     flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
383     Color color = Color_Blue,
384     flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Weapon>>> weapons = 0,
385     Equipment equipped_type = Equipment_NONE,
386     flatbuffers::Offset<void> equipped = 0) {
387   MonsterBuilder builder_(_fbb);
388   builder_.add_equipped(equipped);
389   builder_.add_weapons(weapons);
390   builder_.add_inventory(inventory);
391   builder_.add_name(name);
392   builder_.add_pos(pos);
393   builder_.add_hp(hp);
394   builder_.add_mana(mana);
395   builder_.add_equipped_type(equipped_type);
396   builder_.add_color(color);
397   return builder_.Finish();
398 }
399 
400 inline flatbuffers::Offset<Monster> CreateMonsterDirect(
401     flatbuffers::FlatBufferBuilder &_fbb,
402     const Vec3 *pos = 0,
403     int16_t mana = 150,
404     int16_t hp = 100,
405     const char *name = nullptr,
406     const std::vector<uint8_t> *inventory = nullptr,
407     Color color = Color_Blue,
408     const std::vector<flatbuffers::Offset<Weapon>> *weapons = nullptr,
409     Equipment equipped_type = Equipment_NONE,
410     flatbuffers::Offset<void> equipped = 0) {
411   auto name__ = name ? _fbb.CreateString(name) : 0;
412   auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
413   auto weapons__ = weapons ? _fbb.CreateVector<flatbuffers::Offset<Weapon>>(*weapons) : 0;
414   return MyGame::Sample::CreateMonster(
415       _fbb,
416       pos,
417       mana,
418       hp,
419       name__,
420       inventory__,
421       color,
422       weapons__,
423       equipped_type,
424       equipped);
425 }
426 
427 flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
428 
429 struct WeaponT : public flatbuffers::NativeTable {
430   typedef Weapon TableType;
431   std::string name;
432   int16_t damage;
433   WeaponT()
434       : damage(0) {
435   }
436 };
437 
438 inline bool operator==(const WeaponT &lhs, const WeaponT &rhs) {
439   return
440       (lhs.name == rhs.name) &&
441       (lhs.damage == rhs.damage);
442 }
443 
444 struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
445   typedef WeaponT NativeTableType;
446   static const flatbuffers::TypeTable *MiniReflectTypeTable() {
447     return WeaponTypeTable();
448   }
449   enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
450     VT_NAME = 4,
451     VT_DAMAGE = 6
452   };
453   const flatbuffers::String *name() const {
454     return GetPointer<const flatbuffers::String *>(VT_NAME);
455   }
456   flatbuffers::String *mutable_name() {
457     return GetPointer<flatbuffers::String *>(VT_NAME);
458   }
459   int16_t damage() const {
460     return GetField<int16_t>(VT_DAMAGE, 0);
461   }
462   bool mutate_damage(int16_t _damage) {
463     return SetField<int16_t>(VT_DAMAGE, _damage, 0);
464   }
465   bool Verify(flatbuffers::Verifier &verifier) const {
466     return VerifyTableStart(verifier) &&
467            VerifyOffset(verifier, VT_NAME) &&
468            verifier.VerifyString(name()) &&
469            VerifyField<int16_t>(verifier, VT_DAMAGE) &&
470            verifier.EndTable();
471   }
472   WeaponT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
473   void UnPackTo(WeaponT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
474   static flatbuffers::Offset<Weapon> Pack(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
475 };
476 
477 struct WeaponBuilder {
478   flatbuffers::FlatBufferBuilder &fbb_;
479   flatbuffers::uoffset_t start_;
480   void add_name(flatbuffers::Offset<flatbuffers::String> name) {
481     fbb_.AddOffset(Weapon::VT_NAME, name);
482   }
483   void add_damage(int16_t damage) {
484     fbb_.AddElement<int16_t>(Weapon::VT_DAMAGE, damage, 0);
485   }
486   explicit WeaponBuilder(flatbuffers::FlatBufferBuilder &_fbb)
487         : fbb_(_fbb) {
488     start_ = fbb_.StartTable();
489   }
490   WeaponBuilder &operator=(const WeaponBuilder &);
491   flatbuffers::Offset<Weapon> Finish() {
492     const auto end = fbb_.EndTable(start_);
493     auto o = flatbuffers::Offset<Weapon>(end);
494     return o;
495   }
496 };
497 
498 inline flatbuffers::Offset<Weapon> CreateWeapon(
499     flatbuffers::FlatBufferBuilder &_fbb,
500     flatbuffers::Offset<flatbuffers::String> name = 0,
501     int16_t damage = 0) {
502   WeaponBuilder builder_(_fbb);
503   builder_.add_name(name);
504   builder_.add_damage(damage);
505   return builder_.Finish();
506 }
507 
508 inline flatbuffers::Offset<Weapon> CreateWeaponDirect(
509     flatbuffers::FlatBufferBuilder &_fbb,
510     const char *name = nullptr,
511     int16_t damage = 0) {
512   auto name__ = name ? _fbb.CreateString(name) : 0;
513   return MyGame::Sample::CreateWeapon(
514       _fbb,
515       name__,
516       damage);
517 }
518 
519 flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
520 
521 inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
522   auto _o = new MonsterT();
523   UnPackTo(_o, _resolver);
524   return _o;
525 }
526 
527 inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
528   (void)_o;
529   (void)_resolver;
530   { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<Vec3>(new Vec3(*_e)); };
531   { auto _e = mana(); _o->mana = _e; };
532   { auto _e = hp(); _o->hp = _e; };
533   { auto _e = name(); if (_e) _o->name = _e->str(); };
534   { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inventory[_i] = _e->Get(_i); } } };
535   { auto _e = color(); _o->color = _e; };
536   { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->weapons[_i] = flatbuffers::unique_ptr<WeaponT>(_e->Get(_i)->UnPack(_resolver)); } } };
537   { auto _e = equipped_type(); _o->equipped.type = _e; };
538   { auto _e = equipped(); if (_e) _o->equipped.value = EquipmentUnion::UnPack(_e, equipped_type(), _resolver); };
539 }
540 
541 inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
542   return CreateMonster(_fbb, _o, _rehasher);
543 }
544 
545 inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
546   (void)_rehasher;
547   (void)_o;
548   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
549   auto _pos = _o->pos ? _o->pos.get() : 0;
550   auto _mana = _o->mana;
551   auto _hp = _o->hp;
552   auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
553   auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
554   auto _color = _o->color;
555   auto _weapons = _o->weapons.size() ? _fbb.CreateVector<flatbuffers::Offset<Weapon>> (_o->weapons.size(), [](size_t i, _VectorArgs *__va) { return CreateWeapon(*__va->__fbb, __va->__o->weapons[i].get(), __va->__rehasher); }, &_va ) : 0;
556   auto _equipped_type = _o->equipped.type;
557   auto _equipped = _o->equipped.Pack(_fbb);
558   return MyGame::Sample::CreateMonster(
559       _fbb,
560       _pos,
561       _mana,
562       _hp,
563       _name,
564       _inventory,
565       _color,
566       _weapons,
567       _equipped_type,
568       _equipped);
569 }
570 
571 inline WeaponT *Weapon::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
572   auto _o = new WeaponT();
573   UnPackTo(_o, _resolver);
574   return _o;
575 }
576 
577 inline void Weapon::UnPackTo(WeaponT *_o, const flatbuffers::resolver_function_t *_resolver) const {
578   (void)_o;
579   (void)_resolver;
580   { auto _e = name(); if (_e) _o->name = _e->str(); };
581   { auto _e = damage(); _o->damage = _e; };
582 }
583 
584 inline flatbuffers::Offset<Weapon> Weapon::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
585   return CreateWeapon(_fbb, _o, _rehasher);
586 }
587 
588 inline flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
589   (void)_rehasher;
590   (void)_o;
591   struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WeaponT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
592   auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
593   auto _damage = _o->damage;
594   return MyGame::Sample::CreateWeapon(
595       _fbb,
596       _name,
597       _damage);
598 }
599 
600 inline bool VerifyEquipment(flatbuffers::Verifier &verifier, const void *obj, Equipment type) {
601   switch (type) {
602     case Equipment_NONE: {
603       return true;
604     }
605     case Equipment_Weapon: {
606       auto ptr = reinterpret_cast<const Weapon *>(obj);
607       return verifier.VerifyTable(ptr);
608     }
609     default: return false;
610   }
611 }
612 
613 inline bool VerifyEquipmentVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
614   if (!values || !types) return !values && !types;
615   if (values->size() != types->size()) return false;
616   for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
617     if (!VerifyEquipment(
618         verifier,  values->Get(i), types->GetEnum<Equipment>(i))) {
619       return false;
620     }
621   }
622   return true;
623 }
624 
625 inline void *EquipmentUnion::UnPack(const void *obj, Equipment type, const flatbuffers::resolver_function_t *resolver) {
626   switch (type) {
627     case Equipment_Weapon: {
628       auto ptr = reinterpret_cast<const Weapon *>(obj);
629       return ptr->UnPack(resolver);
630     }
631     default: return nullptr;
632   }
633 }
634 
635 inline flatbuffers::Offset<void> EquipmentUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
636   switch (type) {
637     case Equipment_Weapon: {
638       auto ptr = reinterpret_cast<const WeaponT *>(value);
639       return CreateWeapon(_fbb, ptr, _rehasher).Union();
640     }
641     default: return 0;
642   }
643 }
644 
645 inline EquipmentUnion::EquipmentUnion(const EquipmentUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) {
646   switch (type) {
647     case Equipment_Weapon: {
648       value = new WeaponT(*reinterpret_cast<WeaponT *>(u.value));
649       break;
650     }
651     default:
652       break;
653   }
654 }
655 
656 inline void EquipmentUnion::Reset() {
657   switch (type) {
658     case Equipment_Weapon: {
659       auto ptr = reinterpret_cast<WeaponT *>(value);
660       delete ptr;
661       break;
662     }
663     default: break;
664   }
665   value = nullptr;
666   type = Equipment_NONE;
667 }
668 
669 inline const flatbuffers::TypeTable *ColorTypeTable() {
670   static const flatbuffers::TypeCode type_codes[] = {
671     { flatbuffers::ET_CHAR, 0, 0 },
672     { flatbuffers::ET_CHAR, 0, 0 },
673     { flatbuffers::ET_CHAR, 0, 0 }
674   };
675   static const flatbuffers::TypeFunction type_refs[] = {
676     ColorTypeTable
677   };
678   static const char * const names[] = {
679     "Red",
680     "Green",
681     "Blue"
682   };
683   static const flatbuffers::TypeTable tt = {
684     flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names
685   };
686   return &tt;
687 }
688 
689 inline const flatbuffers::TypeTable *EquipmentTypeTable() {
690   static const flatbuffers::TypeCode type_codes[] = {
691     { flatbuffers::ET_SEQUENCE, 0, -1 },
692     { flatbuffers::ET_SEQUENCE, 0, 0 }
693   };
694   static const flatbuffers::TypeFunction type_refs[] = {
695     WeaponTypeTable
696   };
697   static const char * const names[] = {
698     "NONE",
699     "Weapon"
700   };
701   static const flatbuffers::TypeTable tt = {
702     flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, names
703   };
704   return &tt;
705 }
706 
707 inline const flatbuffers::TypeTable *Vec3TypeTable() {
708   static const flatbuffers::TypeCode type_codes[] = {
709     { flatbuffers::ET_FLOAT, 0, -1 },
710     { flatbuffers::ET_FLOAT, 0, -1 },
711     { flatbuffers::ET_FLOAT, 0, -1 }
712   };
713   static const int64_t values[] = { 0, 4, 8, 12 };
714   static const char * const names[] = {
715     "x",
716     "y",
717     "z"
718   };
719   static const flatbuffers::TypeTable tt = {
720     flatbuffers::ST_STRUCT, 3, type_codes, nullptr, values, names
721   };
722   return &tt;
723 }
724 
725 inline const flatbuffers::TypeTable *MonsterTypeTable() {
726   static const flatbuffers::TypeCode type_codes[] = {
727     { flatbuffers::ET_SEQUENCE, 0, 0 },
728     { flatbuffers::ET_SHORT, 0, -1 },
729     { flatbuffers::ET_SHORT, 0, -1 },
730     { flatbuffers::ET_STRING, 0, -1 },
731     { flatbuffers::ET_BOOL, 0, -1 },
732     { flatbuffers::ET_UCHAR, 1, -1 },
733     { flatbuffers::ET_CHAR, 0, 1 },
734     { flatbuffers::ET_SEQUENCE, 1, 2 },
735     { flatbuffers::ET_UTYPE, 0, 3 },
736     { flatbuffers::ET_SEQUENCE, 0, 3 }
737   };
738   static const flatbuffers::TypeFunction type_refs[] = {
739     Vec3TypeTable,
740     ColorTypeTable,
741     WeaponTypeTable,
742     EquipmentTypeTable
743   };
744   static const char * const names[] = {
745     "pos",
746     "mana",
747     "hp",
748     "name",
749     "friendly",
750     "inventory",
751     "color",
752     "weapons",
753     "equipped_type",
754     "equipped"
755   };
756   static const flatbuffers::TypeTable tt = {
757     flatbuffers::ST_TABLE, 10, type_codes, type_refs, nullptr, names
758   };
759   return &tt;
760 }
761 
762 inline const flatbuffers::TypeTable *WeaponTypeTable() {
763   static const flatbuffers::TypeCode type_codes[] = {
764     { flatbuffers::ET_STRING, 0, -1 },
765     { flatbuffers::ET_SHORT, 0, -1 }
766   };
767   static const char * const names[] = {
768     "name",
769     "damage"
770   };
771   static const flatbuffers::TypeTable tt = {
772     flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, names
773   };
774   return &tt;
775 }
776 
777 inline const MyGame::Sample::Monster *GetMonster(const void *buf) {
778   return flatbuffers::GetRoot<MyGame::Sample::Monster>(buf);
779 }
780 
781 inline const MyGame::Sample::Monster *GetSizePrefixedMonster(const void *buf) {
782   return flatbuffers::GetSizePrefixedRoot<MyGame::Sample::Monster>(buf);
783 }
784 
785 inline Monster *GetMutableMonster(void *buf) {
786   return flatbuffers::GetMutableRoot<Monster>(buf);
787 }
788 
789 inline bool VerifyMonsterBuffer(
790     flatbuffers::Verifier &verifier) {
791   return verifier.VerifyBuffer<MyGame::Sample::Monster>(nullptr);
792 }
793 
794 inline bool VerifySizePrefixedMonsterBuffer(
795     flatbuffers::Verifier &verifier) {
796   return verifier.VerifySizePrefixedBuffer<MyGame::Sample::Monster>(nullptr);
797 }
798 
799 inline void FinishMonsterBuffer(
800     flatbuffers::FlatBufferBuilder &fbb,
801     flatbuffers::Offset<MyGame::Sample::Monster> root) {
802   fbb.Finish(root);
803 }
804 
805 inline void FinishSizePrefixedMonsterBuffer(
806     flatbuffers::FlatBufferBuilder &fbb,
807     flatbuffers::Offset<MyGame::Sample::Monster> root) {
808   fbb.FinishSizePrefixed(root);
809 }
810 
811 inline flatbuffers::unique_ptr<MonsterT> UnPackMonster(
812     const void *buf,
813     const flatbuffers::resolver_function_t *res = nullptr) {
814   return flatbuffers::unique_ptr<MonsterT>(GetMonster(buf)->UnPack(res));
815 }
816 
817 }  // namespace Sample
818 }  // namespace MyGame
819 
820 #endif  // FLATBUFFERS_GENERATED_MONSTER_MYGAME_SAMPLE_H_
821