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