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