• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 
4 #ifndef FLATBUFFERS_GENERATED_UNIONVECTOR_H_
5 #define FLATBUFFERS_GENERATED_UNIONVECTOR_H_
6 
7 #include "flatbuffers/flatbuffers.h"
8 
9 struct MuLan;
10 
11 struct Rapunzel;
12 
13 struct Belle;
14 
15 struct Movie;
16 
17 enum Character {
18   Character_NONE = 0,
19   Character_MuLan = 1,
20   Character_Rapunzel = 2,
21   Character_Belle = 3,
22   Character_MIN = Character_NONE,
23   Character_MAX = Character_Belle
24 };
25 
EnumNamesCharacter()26 inline const char **EnumNamesCharacter() {
27   static const char *names[] = {
28     "NONE",
29     "MuLan",
30     "Rapunzel",
31     "Belle",
32     nullptr
33   };
34   return names;
35 }
36 
EnumNameCharacter(Character e)37 inline const char *EnumNameCharacter(Character e) {
38   const size_t index = static_cast<int>(e);
39   return EnumNamesCharacter()[index];
40 }
41 
42 template<typename T> struct CharacterTraits {
43   static const Character enum_value = Character_NONE;
44 };
45 
46 template<> struct CharacterTraits<MuLan> {
47   static const Character enum_value = Character_MuLan;
48 };
49 
50 template<> struct CharacterTraits<Rapunzel> {
51   static const Character enum_value = Character_Rapunzel;
52 };
53 
54 template<> struct CharacterTraits<Belle> {
55   static const Character enum_value = Character_Belle;
56 };
57 
58 bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type);
59 bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
60 
61 struct MuLan FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
62   enum {
63     VT_SWORD_ATTACK_DAMAGE = 4
64   };
65   int32_t sword_attack_damage() const {
66     return GetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, 0);
67   }
68   bool Verify(flatbuffers::Verifier &verifier) const {
69     return VerifyTableStart(verifier) &&
70            VerifyField<int32_t>(verifier, VT_SWORD_ATTACK_DAMAGE) &&
71            verifier.EndTable();
72   }
73 };
74 
75 struct MuLanBuilder {
76   flatbuffers::FlatBufferBuilder &fbb_;
77   flatbuffers::uoffset_t start_;
78   void add_sword_attack_damage(int32_t sword_attack_damage) {
79     fbb_.AddElement<int32_t>(MuLan::VT_SWORD_ATTACK_DAMAGE, sword_attack_damage, 0);
80   }
81   MuLanBuilder(flatbuffers::FlatBufferBuilder &_fbb)
82         : fbb_(_fbb) {
83     start_ = fbb_.StartTable();
84   }
85   MuLanBuilder &operator=(const MuLanBuilder &);
86   flatbuffers::Offset<MuLan> Finish() {
87     const auto end = fbb_.EndTable(start_, 1);
88     auto o = flatbuffers::Offset<MuLan>(end);
89     return o;
90   }
91 };
92 
93 inline flatbuffers::Offset<MuLan> CreateMuLan(
94     flatbuffers::FlatBufferBuilder &_fbb,
95     int32_t sword_attack_damage = 0) {
96   MuLanBuilder builder_(_fbb);
97   builder_.add_sword_attack_damage(sword_attack_damage);
98   return builder_.Finish();
99 }
100 
101 struct Rapunzel FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
102   enum {
103     VT_HAIR_LENGTH = 4
104   };
105   int32_t hair_length() const {
106     return GetField<int32_t>(VT_HAIR_LENGTH, 0);
107   }
108   bool Verify(flatbuffers::Verifier &verifier) const {
109     return VerifyTableStart(verifier) &&
110            VerifyField<int32_t>(verifier, VT_HAIR_LENGTH) &&
111            verifier.EndTable();
112   }
113 };
114 
115 struct RapunzelBuilder {
116   flatbuffers::FlatBufferBuilder &fbb_;
117   flatbuffers::uoffset_t start_;
118   void add_hair_length(int32_t hair_length) {
119     fbb_.AddElement<int32_t>(Rapunzel::VT_HAIR_LENGTH, hair_length, 0);
120   }
121   RapunzelBuilder(flatbuffers::FlatBufferBuilder &_fbb)
122         : fbb_(_fbb) {
123     start_ = fbb_.StartTable();
124   }
125   RapunzelBuilder &operator=(const RapunzelBuilder &);
126   flatbuffers::Offset<Rapunzel> Finish() {
127     const auto end = fbb_.EndTable(start_, 1);
128     auto o = flatbuffers::Offset<Rapunzel>(end);
129     return o;
130   }
131 };
132 
133 inline flatbuffers::Offset<Rapunzel> CreateRapunzel(
134     flatbuffers::FlatBufferBuilder &_fbb,
135     int32_t hair_length = 0) {
136   RapunzelBuilder builder_(_fbb);
137   builder_.add_hair_length(hair_length);
138   return builder_.Finish();
139 }
140 
141 struct Belle FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
142   enum {
143     VT_BOOKS_READ = 4
144   };
145   int32_t books_read() const {
146     return GetField<int32_t>(VT_BOOKS_READ, 0);
147   }
148   bool Verify(flatbuffers::Verifier &verifier) const {
149     return VerifyTableStart(verifier) &&
150            VerifyField<int32_t>(verifier, VT_BOOKS_READ) &&
151            verifier.EndTable();
152   }
153 };
154 
155 struct BelleBuilder {
156   flatbuffers::FlatBufferBuilder &fbb_;
157   flatbuffers::uoffset_t start_;
158   void add_books_read(int32_t books_read) {
159     fbb_.AddElement<int32_t>(Belle::VT_BOOKS_READ, books_read, 0);
160   }
161   BelleBuilder(flatbuffers::FlatBufferBuilder &_fbb)
162         : fbb_(_fbb) {
163     start_ = fbb_.StartTable();
164   }
165   BelleBuilder &operator=(const BelleBuilder &);
166   flatbuffers::Offset<Belle> Finish() {
167     const auto end = fbb_.EndTable(start_, 1);
168     auto o = flatbuffers::Offset<Belle>(end);
169     return o;
170   }
171 };
172 
173 inline flatbuffers::Offset<Belle> CreateBelle(
174     flatbuffers::FlatBufferBuilder &_fbb,
175     int32_t books_read = 0) {
176   BelleBuilder builder_(_fbb);
177   builder_.add_books_read(books_read);
178   return builder_.Finish();
179 }
180 
181 struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
182   enum {
183     VT_CHARACTERS_TYPE = 4,
184     VT_CHARACTERS = 6
185   };
186   const flatbuffers::Vector<uint8_t> *characters_type() const {
187     return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE);
188   }
189   const flatbuffers::Vector<flatbuffers::Offset<void>> *characters() const {
190     return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS);
191   }
192   bool Verify(flatbuffers::Verifier &verifier) const {
193     return VerifyTableStart(verifier) &&
194            VerifyField<flatbuffers::uoffset_t>(verifier, VT_CHARACTERS_TYPE) &&
195            verifier.Verify(characters_type()) &&
196            VerifyField<flatbuffers::uoffset_t>(verifier, VT_CHARACTERS) &&
197            verifier.Verify(characters()) &&
198            VerifyCharacterVector(verifier, characters(), characters_type()) &&
199            verifier.EndTable();
200   }
201 };
202 
203 struct MovieBuilder {
204   flatbuffers::FlatBufferBuilder &fbb_;
205   flatbuffers::uoffset_t start_;
206   void add_characters_type(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type) {
207     fbb_.AddOffset(Movie::VT_CHARACTERS_TYPE, characters_type);
208   }
209   void add_characters(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters) {
210     fbb_.AddOffset(Movie::VT_CHARACTERS, characters);
211   }
212   MovieBuilder(flatbuffers::FlatBufferBuilder &_fbb)
213         : fbb_(_fbb) {
214     start_ = fbb_.StartTable();
215   }
216   MovieBuilder &operator=(const MovieBuilder &);
217   flatbuffers::Offset<Movie> Finish() {
218     const auto end = fbb_.EndTable(start_, 2);
219     auto o = flatbuffers::Offset<Movie>(end);
220     return o;
221   }
222 };
223 
224 inline flatbuffers::Offset<Movie> CreateMovie(
225     flatbuffers::FlatBufferBuilder &_fbb,
226     flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type = 0,
227     flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters = 0) {
228   MovieBuilder builder_(_fbb);
229   builder_.add_characters(characters);
230   builder_.add_characters_type(characters_type);
231   return builder_.Finish();
232 }
233 
234 inline flatbuffers::Offset<Movie> CreateMovieDirect(
235     flatbuffers::FlatBufferBuilder &_fbb,
236     const std::vector<uint8_t> *characters_type = nullptr,
237     const std::vector<flatbuffers::Offset<void>> *characters = nullptr) {
238   return CreateMovie(
239       _fbb,
240       characters_type ? _fbb.CreateVector<uint8_t>(*characters_type) : 0,
241       characters ? _fbb.CreateVector<flatbuffers::Offset<void>>(*characters) : 0);
242 }
243 
244 inline bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type) {
245   switch (type) {
246     case Character_NONE: {
247       return true;
248     }
249     case Character_MuLan: {
250       auto ptr = reinterpret_cast<const MuLan *>(obj);
251       return verifier.VerifyTable(ptr);
252     }
253     case Character_Rapunzel: {
254       auto ptr = reinterpret_cast<const Rapunzel *>(obj);
255       return verifier.VerifyTable(ptr);
256     }
257     case Character_Belle: {
258       auto ptr = reinterpret_cast<const Belle *>(obj);
259       return verifier.VerifyTable(ptr);
260     }
261     default: return false;
262   }
263 }
264 
265 inline bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
266   if (values->size() != types->size()) return false;
267   for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
268     if (!VerifyCharacter(
269         verifier,  values->Get(i), types->GetEnum<Character>(i))) {
270       return false;
271     }
272   }
273   return true;
274 }
275 
276 inline const Movie *GetMovie(const void *buf) {
277   return flatbuffers::GetRoot<Movie>(buf);
278 }
279 
280 inline const char *MovieIdentifier() {
281   return "MOVI";
282 }
283 
284 inline bool MovieBufferHasIdentifier(const void *buf) {
285   return flatbuffers::BufferHasIdentifier(
286       buf, MovieIdentifier());
287 }
288 
289 inline bool VerifyMovieBuffer(
290     flatbuffers::Verifier &verifier) {
291   return verifier.VerifyBuffer<Movie>(MovieIdentifier());
292 }
293 
294 inline void FinishMovieBuffer(
295     flatbuffers::FlatBufferBuilder &fbb,
296     flatbuffers::Offset<Movie> root) {
297   fbb.Finish(root, MovieIdentifier());
298 }
299 
300 #endif  // FLATBUFFERS_GENERATED_UNIONVECTOR_H_
301