summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2017-01-13 17:44:42 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2017-01-13 17:44:42 -0800
commit7b94eab2b14be37b2134cdb6cb51a2c30cee89eb (patch)
tree3e228320b10303333d39f0cf405a73fa0e3bf41f /tests
parent1a21b545604799e75e253e700c4e48c06cbbc68d (diff)
downloadflatbuffers-7b94eab2b14be37b2134cdb6cb51a2c30cee89eb.tar.gz
flatbuffers-7b94eab2b14be37b2134cdb6cb51a2c30cee89eb.tar.bz2
flatbuffers-7b94eab2b14be37b2134cdb6cb51a2c30cee89eb.zip
Add CodeWriter utility class.
Helps simplify code generation code. Instead of this: code += "inline const " + cpp_qualified_name + " *Get"; code += name; code += "(const void *buf) {\n return flatbuffers::GetRoot<"; code += cpp_qualified_name + ">(buf);\n}\n\n"; You do this: code.SetValue("NAME", struct_def.name); code.SetValue("CPP_NAME", cpp_qualified_name); code += "inline const {{CPP_NAME}} *Get{{NAME}}(const void *buf) {"; code += " return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);"; code += "}"; code += ""; Updated the CPP code generator to use the CodeWriter class. Most of the changes in the generated code are white-space changes, esp. around new lines (since the code generator class automatically appends new lines when appending a string). Actual code changes include: * Renamed "rehasher" to "_rehasher" for consistency with other args in Pack function. * Renamed "union_obj" to "obj: in UnPack function. * Always do "(void)_o;" to prevent unused variable warning in Create function (instead of only doing it if there are no fields) in order to avoid two-passes. * Renamed padding variables from __paddingX to paddingX__. "Each name that contains a double underscore (_ _) [...] is reserved to the implementation for any use." C++ standards 17.4.3.1.2. * Add braces around switch cases. * Calculate index as a separate statement in EnumName function, eg. const size_t index = ...; return EnumNamesX()[index]; vs. return EnumNamesX()[...]; * Stored end table offset in variable in Finish() functions, eg. const auto end = fbb_.EndTable(start_, ...); auto o = flatbuffers::Offset<T>(end); vs. auto o = flatbuffers::Offset<T>(fbb_.EndTable(start, ...)); * Separate reinterpret_cast calls from function calls in Union functions, eg. auto ptr = reinterpret_cast<const T *>(obj); return ptr->UnPack(resolver); vs. return reinterpret_cast<const T *>(obj)->UnPack(resolver); * Removed unecessary (void)(padding__X) no-ops from constructors, eg. Test(int16_t a, int8_t b) : ... { (void)__padding0; // <-- Removed this line. } In the idl_gen_cpp.cpp file itself, I refactored some code generation into new functions: GenParam, GenNativeTable, GenVerifyCall, GenBuilders, GenUnpackFieldStatement, and GenCreateParam. Change-Id: I727b1bd8719d05b7ce33cbce00eb58fda817b25d
Diffstat (limited to 'tests')
-rw-r--r--tests/monster_test_generated.h775
-rw-r--r--tests/namespace_test/namespace_test1_generated.h61
-rw-r--r--tests/namespace_test/namespace_test2_generated.h82
3 files changed, 659 insertions, 259 deletions
diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h
index b5ae9f2f..82df66e9 100644
--- a/tests/monster_test_generated.h
+++ b/tests/monster_test_generated.h
@@ -1,5 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
+
#ifndef FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
#define FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
@@ -37,11 +38,24 @@ enum Color {
};
inline const char **EnumNamesColor() {
- static const char *names[] = { "Red", "Green", "", "", "", "", "", "Blue", nullptr };
+ static const char *names[] = {
+ "Red",
+ "Green",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Blue",
+ nullptr
+ };
return names;
}
-inline const char *EnumNameColor(Color e) { return EnumNamesColor()[static_cast<int>(e) - static_cast<int>(Color_Red)]; }
+inline const char *EnumNameColor(Color e) {
+ const size_t index = static_cast<int>(e) - static_cast<int>(Color_Red);
+ return EnumNamesColor()[index];
+}
enum Any {
Any_NONE = 0,
@@ -53,11 +67,20 @@ enum Any {
};
inline const char **EnumNamesAny() {
- static const char *names[] = { "NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster", nullptr };
+ static const char *names[] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster",
+ nullptr
+ };
return names;
}
-inline const char *EnumNameAny(Any e) { return EnumNamesAny()[static_cast<int>(e)]; }
+inline const char *EnumNameAny(Any e) {
+ const size_t index = static_cast<int>(e);
+ return EnumNamesAny()[index];
+}
template<typename T> struct AnyTraits {
static const Any enum_value = Any_NONE;
@@ -77,12 +100,13 @@ template<> struct AnyTraits<MyGame::Example2::Monster> {
struct AnyUnion {
Any type;
-
flatbuffers::NativeTable *table;
+
AnyUnion() : type(Any_NONE), table(nullptr) {}
AnyUnion(const AnyUnion &);
AnyUnion &operator=(const AnyUnion &);
~AnyUnion() { Reset(); }
+
void Reset();
template <typename T>
@@ -94,32 +118,55 @@ struct AnyUnion {
}
}
- static flatbuffers::NativeTable *UnPack(const void *union_obj, Any type, const flatbuffers::resolver_function_t *resolver);
- flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *rehasher = nullptr) const;
+ static flatbuffers::NativeTable *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
- MonsterT *AsMonster() { return type == Any_Monster ? reinterpret_cast<MonsterT *>(table) : nullptr; }
- TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() { return type == Any_TestSimpleTableWithEnum ? reinterpret_cast<TestSimpleTableWithEnumT *>(table) : nullptr; }
- MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() { return type == Any_MyGame_Example2_Monster ? reinterpret_cast<MyGame::Example2::MonsterT *>(table) : nullptr; }
+ MonsterT *AsMonster() {
+ return type == Any_Monster ?
+ reinterpret_cast<MonsterT *>(table) : nullptr;
+ }
+ TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<TestSimpleTableWithEnumT *>(table) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(table) : nullptr;
+ }
};
-inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type);
+bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type);
MANUALLY_ALIGNED_STRUCT(2) Test FLATBUFFERS_FINAL_CLASS {
private:
int16_t a_;
int8_t b_;
- int8_t __padding0;
+ int8_t padding0__;
public:
- Test() { memset(this, 0, sizeof(Test)); }
- Test(const Test &_o) { memcpy(this, &_o, sizeof(Test)); }
+ Test() {
+ memset(this, 0, sizeof(Test));
+ }
+ Test(const Test &_o) {
+ memcpy(this, &_o, sizeof(Test));
+ }
Test(int16_t _a, int8_t _b)
- : a_(flatbuffers::EndianScalar(_a)), b_(flatbuffers::EndianScalar(_b)), __padding0(0) { (void)__padding0; }
-
- int16_t a() const { return flatbuffers::EndianScalar(a_); }
- void mutate_a(int16_t _a) { flatbuffers::WriteScalar(&a_, _a); }
- int8_t b() const { return flatbuffers::EndianScalar(b_); }
- void mutate_b(int8_t _b) { flatbuffers::WriteScalar(&b_, _b); }
+ : a_(flatbuffers::EndianScalar(_a)),
+ b_(flatbuffers::EndianScalar(_b)),
+ padding0__(0) {
+ }
+ int16_t a() const {
+ return flatbuffers::EndianScalar(a_);
+ }
+ void mutate_a(int16_t _a) {
+ flatbuffers::WriteScalar(&a_, _a);
+ }
+ int8_t b() const {
+ return flatbuffers::EndianScalar(b_);
+ }
+ void mutate_b(int8_t _b) {
+ flatbuffers::WriteScalar(&b_, _b);
+ }
};
STRUCT_END(Test, 4);
@@ -128,31 +175,67 @@ MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
float x_;
float y_;
float z_;
- int32_t __padding0;
+ int32_t padding0__;
double test1_;
int8_t test2_;
- int8_t __padding1;
+ int8_t padding1__;
Test test3_;
- int16_t __padding2;
+ int16_t padding2__;
public:
- Vec3() { memset(this, 0, sizeof(Vec3)); }
- Vec3(const Vec3 &_o) { memcpy(this, &_o, sizeof(Vec3)); }
+ Vec3() {
+ memset(this, 0, sizeof(Vec3));
+ }
+ Vec3(const Vec3 &_o) {
+ memcpy(this, &_o, sizeof(Vec3));
+ }
Vec3(float _x, float _y, float _z, double _test1, Color _test2, const Test &_test3)
- : x_(flatbuffers::EndianScalar(_x)), y_(flatbuffers::EndianScalar(_y)), z_(flatbuffers::EndianScalar(_z)), __padding0(0), test1_(flatbuffers::EndianScalar(_test1)), test2_(flatbuffers::EndianScalar(static_cast<int8_t>(_test2))), __padding1(0), test3_(_test3), __padding2(0) { (void)__padding0; (void)__padding1; (void)__padding2; }
-
- float x() const { return flatbuffers::EndianScalar(x_); }
- void mutate_x(float _x) { flatbuffers::WriteScalar(&x_, _x); }
- float y() const { return flatbuffers::EndianScalar(y_); }
- void mutate_y(float _y) { flatbuffers::WriteScalar(&y_, _y); }
- float z() const { return flatbuffers::EndianScalar(z_); }
- void mutate_z(float _z) { flatbuffers::WriteScalar(&z_, _z); }
- double test1() const { return flatbuffers::EndianScalar(test1_); }
- void mutate_test1(double _test1) { flatbuffers::WriteScalar(&test1_, _test1); }
- Color test2() const { return static_cast<Color>(flatbuffers::EndianScalar(test2_)); }
- void mutate_test2(Color _test2) { flatbuffers::WriteScalar(&test2_, static_cast<int8_t>(_test2)); }
- const Test &test3() const { return test3_; }
- Test &mutable_test3() { return test3_; }
+ : x_(flatbuffers::EndianScalar(_x)),
+ y_(flatbuffers::EndianScalar(_y)),
+ z_(flatbuffers::EndianScalar(_z)),
+ padding0__(0),
+ test1_(flatbuffers::EndianScalar(_test1)),
+ test2_(flatbuffers::EndianScalar(static_cast<int8_t>(_test2))),
+ padding1__(0),
+ test3_(_test3),
+ padding2__(0) {
+ }
+ float x() const {
+ return flatbuffers::EndianScalar(x_);
+ }
+ void mutate_x(float _x) {
+ flatbuffers::WriteScalar(&x_, _x);
+ }
+ float y() const {
+ return flatbuffers::EndianScalar(y_);
+ }
+ void mutate_y(float _y) {
+ flatbuffers::WriteScalar(&y_, _y);
+ }
+ float z() const {
+ return flatbuffers::EndianScalar(z_);
+ }
+ void mutate_z(float _z) {
+ flatbuffers::WriteScalar(&z_, _z);
+ }
+ double test1() const {
+ return flatbuffers::EndianScalar(test1_);
+ }
+ void mutate_test1(double _test1) {
+ flatbuffers::WriteScalar(&test1_, _test1);
+ }
+ Color test2() const {
+ return static_cast<Color>(flatbuffers::EndianScalar(test2_));
+ }
+ void mutate_test2(Color _test2) {
+ flatbuffers::WriteScalar(&test2_, static_cast<int8_t>(_test2));
+ }
+ const Test &test3() const {
+ return test3_;
+ }
+ const Test &mutable_test3() {
+ return test3_;
+ }
};
STRUCT_END(Vec3, 32);
@@ -162,7 +245,8 @@ namespace Example2 {
struct MonsterT : public flatbuffers::NativeTable {
typedef Monster TableType;
- MonsterT() {}
+ MonsterT() {
+ }
};
struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
@@ -178,20 +262,25 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
struct MonsterBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
- MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
MonsterBuilder &operator=(const MonsterBuilder &);
flatbuffers::Offset<Monster> Finish() {
- auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 0));
+ const auto end = fbb_.EndTable(start_, 0);
+ auto o = flatbuffers::Offset<Monster>(end);
return o;
}
};
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb) {
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb) {
MonsterBuilder builder_(_fbb);
return builder_.Finish();
}
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *rehasher = nullptr);
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
} // namespace Example2
@@ -201,7 +290,8 @@ struct TestSimpleTableWithEnumT : public flatbuffers::NativeTable {
typedef TestSimpleTableWithEnum TableType;
Color color;
TestSimpleTableWithEnumT()
- : color(Color_Green) {}
+ : color(Color_Green) {
+ }
};
struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
@@ -209,8 +299,12 @@ struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Ta
enum {
VT_COLOR = 4
};
- Color color() const { return static_cast<Color>(GetField<int8_t>(VT_COLOR, 2)); }
- bool mutate_color(Color _color) { return SetField(VT_COLOR, static_cast<int8_t>(_color)); }
+ Color color() const {
+ return static_cast<Color>(GetField<int8_t>(VT_COLOR, 2));
+ }
+ bool mutate_color(Color _color) {
+ return SetField(VT_COLOR, static_cast<int8_t>(_color));
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int8_t>(verifier, VT_COLOR) &&
@@ -226,22 +320,27 @@ struct TestSimpleTableWithEnumBuilder {
void add_color(Color color) {
fbb_.AddElement<int8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<int8_t>(color), 2);
}
- TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
TestSimpleTableWithEnumBuilder &operator=(const TestSimpleTableWithEnumBuilder &);
flatbuffers::Offset<TestSimpleTableWithEnum> Finish() {
- auto o = flatbuffers::Offset<TestSimpleTableWithEnum>(fbb_.EndTable(start_, 1));
+ const auto end = fbb_.EndTable(start_, 1);
+ auto o = flatbuffers::Offset<TestSimpleTableWithEnum>(end);
return o;
}
};
-inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(
+ flatbuffers::FlatBufferBuilder &_fbb,
Color color = Color_Green) {
TestSimpleTableWithEnumBuilder builder_(_fbb);
builder_.add_color(color);
return builder_.Finish();
}
-inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *rehasher = nullptr);
+flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct StatT : public flatbuffers::NativeTable {
typedef Stat TableType;
@@ -249,8 +348,9 @@ struct StatT : public flatbuffers::NativeTable {
int64_t val;
uint16_t count;
StatT()
- : val(0),
- count(0) {}
+ : val(0),
+ count(0) {
+ }
};
struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
@@ -260,12 +360,24 @@ struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_VAL = 6,
VT_COUNT = 8
};
- const flatbuffers::String *id() const { return GetPointer<const flatbuffers::String *>(VT_ID); }
- flatbuffers::String *mutable_id() { return GetPointer<flatbuffers::String *>(VT_ID); }
- int64_t val() const { return GetField<int64_t>(VT_VAL, 0); }
- bool mutate_val(int64_t _val) { return SetField(VT_VAL, _val); }
- uint16_t count() const { return GetField<uint16_t>(VT_COUNT, 0); }
- bool mutate_count(uint16_t _count) { return SetField(VT_COUNT, _count); }
+ const flatbuffers::String *id() const {
+ return GetPointer<const flatbuffers::String *>(VT_ID);
+ }
+ flatbuffers::String *mutable_id() {
+ return GetPointer<flatbuffers::String *>(VT_ID);
+ }
+ int64_t val() const {
+ return GetField<int64_t>(VT_VAL, 0);
+ }
+ bool mutate_val(int64_t _val) {
+ return SetField(VT_VAL, _val);
+ }
+ uint16_t count() const {
+ return GetField<uint16_t>(VT_COUNT, 0);
+ }
+ bool mutate_count(uint16_t _count) {
+ return SetField(VT_COUNT, _count);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, VT_ID) &&
@@ -290,15 +402,20 @@ struct StatBuilder {
void add_count(uint16_t count) {
fbb_.AddElement<uint16_t>(Stat::VT_COUNT, count, 0);
}
- StatBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ StatBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
StatBuilder &operator=(const StatBuilder &);
flatbuffers::Offset<Stat> Finish() {
- auto o = flatbuffers::Offset<Stat>(fbb_.EndTable(start_, 3));
+ const auto end = fbb_.EndTable(start_, 3);
+ auto o = flatbuffers::Offset<Stat>(end);
return o;
}
};
-inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<Stat> CreateStat(
+ flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::String> id = 0,
int64_t val = 0,
uint16_t count = 0) {
@@ -309,14 +426,19 @@ inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb
return builder_.Finish();
}
-inline flatbuffers::Offset<Stat> CreateStatDirect(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<Stat> CreateStatDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
const char *id = nullptr,
int64_t val = 0,
uint16_t count = 0) {
- return CreateStat(_fbb, id ? _fbb.CreateString(id) : 0, val, count);
+ return CreateStat(
+ _fbb,
+ id ? _fbb.CreateString(id) : 0,
+ val,
+ count);
}
-inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *rehasher = nullptr);
+flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
struct MonsterT : public flatbuffers::NativeTable {
typedef Monster TableType;
@@ -348,21 +470,22 @@ struct MonsterT : public flatbuffers::NativeTable {
float testf3;
std::vector<std::string> testarrayofstring2;
MonsterT()
- : mana(150),
- hp(100),
- color(Color_Blue),
- testbool(false),
- testhashs32_fnv1(0),
- testhashu32_fnv1(0),
- testhashs64_fnv1(0),
- testhashu64_fnv1(0),
- testhashs32_fnv1a(0),
- testhashu32_fnv1a(0),
- testhashs64_fnv1a(0),
- testhashu64_fnv1a(0),
- testf(3.14159f),
- testf2(3.0f),
- testf3(0.0f) {}
+ : mana(150),
+ hp(100),
+ color(Color_Blue),
+ testbool(false),
+ testhashs32_fnv1(0),
+ testhashu32_fnv1(0),
+ testhashs64_fnv1(0),
+ testhashu64_fnv1(0),
+ testhashs32_fnv1a(0),
+ testhashu32_fnv1a(0),
+ testhashs64_fnv1a(0),
+ testhashu64_fnv1a(0),
+ testf(3.14159f),
+ testf2(3.0f),
+ testf3(0.0f) {
+ }
};
/// an example documentation comment: monster object
@@ -398,67 +521,186 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_TESTF3 = 58,
VT_TESTARRAYOFSTRING2 = 60
};
- const Vec3 *pos() const { return GetStruct<const Vec3 *>(VT_POS); }
- Vec3 *mutable_pos() { return GetStruct<Vec3 *>(VT_POS); }
- int16_t mana() const { return GetField<int16_t>(VT_MANA, 150); }
- bool mutate_mana(int16_t _mana) { return SetField(VT_MANA, _mana); }
- int16_t hp() const { return GetField<int16_t>(VT_HP, 100); }
- bool mutate_hp(int16_t _hp) { return SetField(VT_HP, _hp); }
- const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); }
- flatbuffers::String *mutable_name() { return GetPointer<flatbuffers::String *>(VT_NAME); }
- bool KeyCompareLessThan(const Monster *o) const { return *name() < *o->name(); }
- int KeyCompareWithValue(const char *val) const { return strcmp(name()->c_str(), val); }
- const flatbuffers::Vector<uint8_t> *inventory() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY); }
- flatbuffers::Vector<uint8_t> *mutable_inventory() { return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY); }
- Color color() const { return static_cast<Color>(GetField<int8_t>(VT_COLOR, 8)); }
- bool mutate_color(Color _color) { return SetField(VT_COLOR, static_cast<int8_t>(_color)); }
- Any test_type() const { return static_cast<Any>(GetField<uint8_t>(VT_TEST_TYPE, 0)); }
- bool mutate_test_type(Any _test_type) { return SetField(VT_TEST_TYPE, static_cast<uint8_t>(_test_type)); }
- const void *test() const { return GetPointer<const void *>(VT_TEST); }
- void *mutable_test() { return GetPointer<void *>(VT_TEST); }
- const flatbuffers::Vector<const Test *> *test4() const { return GetPointer<const flatbuffers::Vector<const Test *> *>(VT_TEST4); }
- flatbuffers::Vector<const Test *> *mutable_test4() { return GetPointer<flatbuffers::Vector<const Test *> *>(VT_TEST4); }
- const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING); }
- flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring() { return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING); }
+ const Vec3 *pos() const {
+ return GetStruct<const Vec3 *>(VT_POS);
+ }
+ Vec3 *mutable_pos() {
+ return GetStruct<Vec3 *>(VT_POS);
+ }
+ int16_t mana() const {
+ return GetField<int16_t>(VT_MANA, 150);
+ }
+ bool mutate_mana(int16_t _mana) {
+ return SetField(VT_MANA, _mana);
+ }
+ int16_t hp() const {
+ return GetField<int16_t>(VT_HP, 100);
+ }
+ bool mutate_hp(int16_t _hp) {
+ return SetField(VT_HP, _hp);
+ }
+ const flatbuffers::String *name() const {
+ return GetPointer<const flatbuffers::String *>(VT_NAME);
+ }
+ flatbuffers::String *mutable_name() {
+ return GetPointer<flatbuffers::String *>(VT_NAME);
+ }
+ bool KeyCompareLessThan(const Monster *o) const {
+ return *name() < *o->name();
+ }
+ int KeyCompareWithValue(const char *val) const {
+ return strcmp(name()->c_str(), val);
+ }
+ const flatbuffers::Vector<uint8_t> *inventory() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_inventory() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ Color color() const {
+ return static_cast<Color>(GetField<int8_t>(VT_COLOR, 8));
+ }
+ bool mutate_color(Color _color) {
+ return SetField(VT_COLOR, static_cast<int8_t>(_color));
+ }
+ Any test_type() const {
+ return static_cast<Any>(GetField<uint8_t>(VT_TEST_TYPE, 0));
+ }
+ bool mutate_test_type(Any _test_type) {
+ return SetField(VT_TEST_TYPE, static_cast<uint8_t>(_test_type));
+ }
+ const void *test() const {
+ return GetPointer<const void *>(VT_TEST);
+ }
+ void *mutable_test() {
+ return GetPointer<void *>(VT_TEST);
+ }
+ const flatbuffers::Vector<const Test *> *test4() const {
+ return GetPointer<const flatbuffers::Vector<const Test *> *>(VT_TEST4);
+ }
+ flatbuffers::Vector<const Test *> *mutable_test4() {
+ return GetPointer<flatbuffers::Vector<const Test *> *>(VT_TEST4);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
/// an example documentation comment: this will end up in the generated code
/// multiline too
- const flatbuffers::Vector<flatbuffers::Offset<Monster>> *testarrayoftables() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Monster>> *>(VT_TESTARRAYOFTABLES); }
- flatbuffers::Vector<flatbuffers::Offset<Monster>> *mutable_testarrayoftables() { return GetPointer<flatbuffers::Vector<flatbuffers::Offset<Monster>> *>(VT_TESTARRAYOFTABLES); }
- const Monster *enemy() const { return GetPointer<const Monster *>(VT_ENEMY); }
- Monster *mutable_enemy() { return GetPointer<Monster *>(VT_ENEMY); }
- const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER); }
- flatbuffers::Vector<uint8_t> *mutable_testnestedflatbuffer() { return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER); }
- const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const { return flatbuffers::GetRoot<MyGame::Example::Monster>(testnestedflatbuffer()->Data()); }
- const Stat *testempty() const { return GetPointer<const Stat *>(VT_TESTEMPTY); }
- Stat *mutable_testempty() { return GetPointer<Stat *>(VT_TESTEMPTY); }
- bool testbool() const { return GetField<uint8_t>(VT_TESTBOOL, 0) != 0; }
- bool mutate_testbool(bool _testbool) { return SetField(VT_TESTBOOL, static_cast<uint8_t>(_testbool)); }
- int32_t testhashs32_fnv1() const { return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0); }
- bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1) { return SetField(VT_TESTHASHS32_FNV1, _testhashs32_fnv1); }
- uint32_t testhashu32_fnv1() const { return GetField<uint32_t>(VT_TESTHASHU32_FNV1, 0); }
- bool mutate_testhashu32_fnv1(uint32_t _testhashu32_fnv1) { return SetField(VT_TESTHASHU32_FNV1, _testhashu32_fnv1); }
- int64_t testhashs64_fnv1() const { return GetField<int64_t>(VT_TESTHASHS64_FNV1, 0); }
- bool mutate_testhashs64_fnv1(int64_t _testhashs64_fnv1) { return SetField(VT_TESTHASHS64_FNV1, _testhashs64_fnv1); }
- uint64_t testhashu64_fnv1() const { return GetField<uint64_t>(VT_TESTHASHU64_FNV1, 0); }
- bool mutate_testhashu64_fnv1(uint64_t _testhashu64_fnv1) { return SetField(VT_TESTHASHU64_FNV1, _testhashu64_fnv1); }
- int32_t testhashs32_fnv1a() const { return GetField<int32_t>(VT_TESTHASHS32_FNV1A, 0); }
- bool mutate_testhashs32_fnv1a(int32_t _testhashs32_fnv1a) { return SetField(VT_TESTHASHS32_FNV1A, _testhashs32_fnv1a); }
- uint32_t testhashu32_fnv1a() const { return GetField<uint32_t>(VT_TESTHASHU32_FNV1A, 0); }
- bool mutate_testhashu32_fnv1a(uint32_t _testhashu32_fnv1a) { return SetField(VT_TESTHASHU32_FNV1A, _testhashu32_fnv1a); }
- int64_t testhashs64_fnv1a() const { return GetField<int64_t>(VT_TESTHASHS64_FNV1A, 0); }
- bool mutate_testhashs64_fnv1a(int64_t _testhashs64_fnv1a) { return SetField(VT_TESTHASHS64_FNV1A, _testhashs64_fnv1a); }
- uint64_t testhashu64_fnv1a() const { return GetField<uint64_t>(VT_TESTHASHU64_FNV1A, 0); }
- bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a) { return SetField(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a); }
- const flatbuffers::Vector<uint8_t> *testarrayofbools() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS); }
- flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() { return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS); }
- float testf() const { return GetField<float>(VT_TESTF, 3.14159f); }
- bool mutate_testf(float _testf) { return SetField(VT_TESTF, _testf); }
- float testf2() const { return GetField<float>(VT_TESTF2, 3.0f); }
- bool mutate_testf2(float _testf2) { return SetField(VT_TESTF2, _testf2); }
- float testf3() const { return GetField<float>(VT_TESTF3, 0.0f); }
- bool mutate_testf3(float _testf3) { return SetField(VT_TESTF3, _testf3); }
- const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2); }
- flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() { return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2); }
+ const flatbuffers::Vector<flatbuffers::Offset<Monster>> *testarrayoftables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<Monster>> *mutable_testarrayoftables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ const Monster *enemy() const {
+ return GetPointer<const Monster *>(VT_ENEMY);
+ }
+ Monster *mutable_enemy() {
+ return GetPointer<Monster *>(VT_ENEMY);
+ }
+ const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testnestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const {
+ const uint8_t* data = testnestedflatbuffer()->Data();
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(data);
+ }
+ const Stat *testempty() const {
+ return GetPointer<const Stat *>(VT_TESTEMPTY);
+ }
+ Stat *mutable_testempty() {
+ return GetPointer<Stat *>(VT_TESTEMPTY);
+ }
+ bool testbool() const {
+ return GetField<uint8_t>(VT_TESTBOOL, 0) != 0;
+ }
+ bool mutate_testbool(bool _testbool) {
+ return SetField(VT_TESTBOOL, static_cast<uint8_t>(_testbool));
+ }
+ int32_t testhashs32_fnv1() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0);
+ }
+ bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1) {
+ return SetField(VT_TESTHASHS32_FNV1, _testhashs32_fnv1);
+ }
+ uint32_t testhashu32_fnv1() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1, 0);
+ }
+ bool mutate_testhashu32_fnv1(uint32_t _testhashu32_fnv1) {
+ return SetField(VT_TESTHASHU32_FNV1, _testhashu32_fnv1);
+ }
+ int64_t testhashs64_fnv1() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1, 0);
+ }
+ bool mutate_testhashs64_fnv1(int64_t _testhashs64_fnv1) {
+ return SetField(VT_TESTHASHS64_FNV1, _testhashs64_fnv1);
+ }
+ uint64_t testhashu64_fnv1() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1, 0);
+ }
+ bool mutate_testhashu64_fnv1(uint64_t _testhashu64_fnv1) {
+ return SetField(VT_TESTHASHU64_FNV1, _testhashu64_fnv1);
+ }
+ int32_t testhashs32_fnv1a() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1A, 0);
+ }
+ bool mutate_testhashs32_fnv1a(int32_t _testhashs32_fnv1a) {
+ return SetField(VT_TESTHASHS32_FNV1A, _testhashs32_fnv1a);
+ }
+ uint32_t testhashu32_fnv1a() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1A, 0);
+ }
+ bool mutate_testhashu32_fnv1a(uint32_t _testhashu32_fnv1a) {
+ return SetField(VT_TESTHASHU32_FNV1A, _testhashu32_fnv1a);
+ }
+ int64_t testhashs64_fnv1a() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1A, 0);
+ }
+ bool mutate_testhashs64_fnv1a(int64_t _testhashs64_fnv1a) {
+ return SetField(VT_TESTHASHS64_FNV1A, _testhashs64_fnv1a);
+ }
+ uint64_t testhashu64_fnv1a() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1A, 0);
+ }
+ bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a) {
+ return SetField(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a);
+ }
+ const flatbuffers::Vector<uint8_t> *testarrayofbools() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ float testf() const {
+ return GetField<float>(VT_TESTF, 3.14159f);
+ }
+ bool mutate_testf(float _testf) {
+ return SetField(VT_TESTF, _testf);
+ }
+ float testf2() const {
+ return GetField<float>(VT_TESTF2, 3.0f);
+ }
+ bool mutate_testf2(float _testf2) {
+ return SetField(VT_TESTF2, _testf2);
+ }
+ float testf3() const {
+ return GetField<float>(VT_TESTF3, 0.0f);
+ }
+ bool mutate_testf3(float _testf3) {
+ return SetField(VT_TESTF3, _testf3);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<Vec3>(verifier, VT_POS) &&
@@ -596,16 +838,21 @@ struct MonsterBuilder {
void add_testarrayofstring2(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2) {
fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2);
}
- MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
MonsterBuilder &operator=(const MonsterBuilder &);
flatbuffers::Offset<Monster> Finish() {
- auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 29));
- fbb_.Required(o, Monster::VT_NAME); // name
+ const auto end = fbb_.EndTable(start_, 29);
+ auto o = flatbuffers::Offset<Monster>(end);
+ fbb_.Required(o, Monster::VT_NAME);
return o;
}
};
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb,
const Vec3 *pos = 0,
int16_t mana = 150,
int16_t hp = 100,
@@ -666,7 +913,8 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
return builder_.Finish();
}
-inline flatbuffers::Offset<Monster> CreateMonsterDirect(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<Monster> CreateMonsterDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
const Vec3 *pos = 0,
int16_t mana = 150,
int16_t hp = 100,
@@ -695,10 +943,39 @@ inline flatbuffers::Offset<Monster> CreateMonsterDirect(flatbuffers::FlatBufferB
float testf2 = 3.0f,
float testf3 = 0.0f,
const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr) {
- return CreateMonster(_fbb, pos, mana, hp, name ? _fbb.CreateString(name) : 0, inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0, color, test_type, test, test4 ? _fbb.CreateVector<const Test *>(*test4) : 0, testarrayofstring ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring) : 0, testarrayoftables ? _fbb.CreateVector<flatbuffers::Offset<Monster>>(*testarrayoftables) : 0, enemy, testnestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testnestedflatbuffer) : 0, testempty, testbool, testhashs32_fnv1, testhashu32_fnv1, testhashs64_fnv1, testhashu64_fnv1, testhashs32_fnv1a, testhashu32_fnv1a, testhashs64_fnv1a, testhashu64_fnv1a, testarrayofbools ? _fbb.CreateVector<uint8_t>(*testarrayofbools) : 0, testf, testf2, testf3, testarrayofstring2 ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2) : 0);
+ return CreateMonster(
+ _fbb,
+ pos,
+ mana,
+ hp,
+ name ? _fbb.CreateString(name) : 0,
+ inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0,
+ color,
+ test_type,
+ test,
+ test4 ? _fbb.CreateVector<const Test *>(*test4) : 0,
+ testarrayofstring ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring) : 0,
+ testarrayoftables ? _fbb.CreateVector<flatbuffers::Offset<Monster>>(*testarrayoftables) : 0,
+ enemy,
+ testnestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testnestedflatbuffer) : 0,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools ? _fbb.CreateVector<uint8_t>(*testarrayofbools) : 0,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2 ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2) : 0);
}
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *rehasher = nullptr);
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
} // namespace Example
@@ -714,10 +991,11 @@ inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder
return CreateMonster(_fbb, _o, _rehasher);
}
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *rehasher) {
- (void)rehasher;
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
(void)_o;
- return CreateMonster(_fbb);
+ return CreateMonster(
+ _fbb);
}
} // namespace Example2
@@ -735,10 +1013,12 @@ inline flatbuffers::Offset<TestSimpleTableWithEnum> TestSimpleTableWithEnum::Pac
return CreateTestSimpleTableWithEnum(_fbb, _o, _rehasher);
}
-inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *rehasher) {
- (void)rehasher;
- return CreateTestSimpleTableWithEnum(_fbb,
- _o->color);
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ return CreateTestSimpleTableWithEnum(
+ _fbb,
+ _o->color);
}
inline StatT *Stat::UnPack(const flatbuffers::resolver_function_t *resolver) const {
@@ -754,12 +1034,14 @@ inline flatbuffers::Offset<Stat> Stat::Pack(flatbuffers::FlatBufferBuilder &_fbb
return CreateStat(_fbb, _o, _rehasher);
}
-inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *rehasher) {
- (void)rehasher;
- return CreateStat(_fbb,
- _o->id.size() ? _fbb.CreateString(_o->id) : 0,
- _o->val,
- _o->count);
+inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ return CreateStat(
+ _fbb,
+ _o->id.size() ? _fbb.CreateString(_o->id) : 0,
+ _o->val,
+ _o->count);
}
inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *resolver) const {
@@ -769,15 +1051,15 @@ inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *resolve
{ auto _e = mana(); _o->mana = _e; };
{ auto _e = hp(); _o->hp = _e; };
{ auto _e = name(); if (_e) _o->name = _e->str(); };
- { auto _e = inventory(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inventory.push_back(_e->Get(_i)); } } };
+ { auto _e = inventory(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inventory.push_back(_e->Get(_i)); } };
{ auto _e = color(); _o->color = _e; };
{ auto _e = test_type(); _o->test.type = _e; };
- { auto _e = test(); if (_e) _o->test.table = AnyUnion::UnPack(_e, test_type(), resolver); };
- { auto _e = test4(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4.push_back(*_e->Get(_i)); } } };
- { auto _e = testarrayofstring(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring.push_back(_e->Get(_i)->str()); } } };
- { auto _e = testarrayoftables(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayoftables.push_back(std::unique_ptr<MonsterT>(_e->Get(_i)->UnPack(resolver))); } } };
+ { auto _e = test(); if (_e) _o->test.table = AnyUnion::UnPack(_e, test_type(),resolver); };
+ { auto _e = test4(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4.push_back(*_e->Get(_i)); } };
+ { auto _e = testarrayofstring(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring.push_back(_e->Get(_i)->str()); } };
+ { auto _e = testarrayoftables(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayoftables.push_back(std::unique_ptr<MonsterT>(_e->Get(_i)->UnPack(resolver))); } };
{ auto _e = enemy(); if (_e) _o->enemy = std::unique_ptr<MonsterT>(_e->UnPack(resolver)); };
- { auto _e = testnestedflatbuffer(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testnestedflatbuffer.push_back(_e->Get(_i)); } } };
+ { auto _e = testnestedflatbuffer(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testnestedflatbuffer.push_back(_e->Get(_i)); } };
{ auto _e = testempty(); if (_e) _o->testempty = std::unique_ptr<StatT>(_e->UnPack(resolver)); };
{ auto _e = testbool(); _o->testbool = _e; };
{ auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; };
@@ -788,11 +1070,11 @@ inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *resolve
{ auto _e = testhashu32_fnv1a(); if (resolver) (*resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; };
{ auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; };
{ auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; };
- { auto _e = testarrayofbools(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools.push_back(_e->Get(_i)!=0); } } };
+ { auto _e = testarrayofbools(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools.push_back(_e->Get(_i) != 0); } };
{ auto _e = testf(); _o->testf = _e; };
{ auto _e = testf2(); _o->testf2 = _e; };
{ auto _e = testf3(); _o->testf3 = _e; };
- { auto _e = testarrayofstring2(); if (_e) { for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2.push_back(_e->Get(_i)->str()); } } };
+ { auto _e = testarrayofstring2(); if (_e) for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2.push_back(_e->Get(_i)->str()); } };
return _o;
}
@@ -800,74 +1082,115 @@ inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder
return CreateMonster(_fbb, _o, _rehasher);
}
-inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *rehasher) {
- (void)rehasher;
- return CreateMonster(_fbb,
- _o->pos ? _o->pos.get() : 0,
- _o->mana,
- _o->hp,
- _fbb.CreateString(_o->name),
- _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0,
- _o->color,
- _o->test.type,
- _o->test.Pack(_fbb),
- _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 0,
- _o->testarrayofstring.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring) : 0,
- _o->testarrayoftables.size() ? _fbb.CreateVector<flatbuffers::Offset<Monster>>(_o->testarrayoftables.size(), [&](size_t i) { return CreateMonster(_fbb, _o->testarrayoftables[i].get(), rehasher); }) : 0,
- _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), rehasher) : 0,
- _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0,
- _o->testempty ? CreateStat(_fbb, _o->testempty.get(), rehasher) : 0,
- _o->testbool,
- _o->testhashs32_fnv1,
- _o->testhashu32_fnv1,
- _o->testhashs64_fnv1,
- _o->testhashu64_fnv1,
- _o->testhashs32_fnv1a,
- rehasher ? static_cast<uint32_t>((*rehasher)(_o->testhashu32_fnv1a)) : 0,
- _o->testhashs64_fnv1a,
- _o->testhashu64_fnv1a,
- _o->testarrayofbools.size() ? _fbb.CreateVector(_o->testarrayofbools) : 0,
- _o->testf,
- _o->testf2,
- _o->testf3,
- _o->testarrayofstring2.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring2) : 0);
-}
-
-inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type) {
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ return CreateMonster(
+ _fbb,
+ _o->pos ? _o->pos.get() : 0,
+ _o->mana,
+ _o->hp,
+ _fbb.CreateString(_o->name),
+ _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0,
+ _o->color,
+ _o->test.type,
+ _o->test.Pack(_fbb),
+ _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 0,
+ _o->testarrayofstring.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring) : 0,
+ _o->testarrayoftables.size() ? _fbb.CreateVector<flatbuffers::Offset<Monster>>(_o->testarrayoftables.size(), [&](size_t i) { return CreateMonster(_fbb, _o->testarrayoftables[i].get(), _rehasher); }) : 0,
+ _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0,
+ _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0,
+ _o->testempty ? CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0,
+ _o->testbool,
+ _o->testhashs32_fnv1,
+ _o->testhashu32_fnv1,
+ _o->testhashs64_fnv1,
+ _o->testhashu64_fnv1,
+ _o->testhashs32_fnv1a,
+ _rehasher ? static_cast<uint32_t>((*_rehasher)(_o->testhashu32_fnv1a)) : 0,
+ _o->testhashs64_fnv1a,
+ _o->testhashu64_fnv1a,
+ _o->testarrayofbools.size() ? _fbb.CreateVector(_o->testarrayofbools) : 0,
+ _o->testf,
+ _o->testf2,
+ _o->testf3,
+ _o->testarrayofstring2.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring2) : 0);
+}
+
+inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type) {
switch (type) {
- case Any_NONE: return true;
- case Any_Monster: return verifier.VerifyTable(reinterpret_cast<const Monster *>(union_obj));
- case Any_TestSimpleTableWithEnum: return verifier.VerifyTable(reinterpret_cast<const TestSimpleTableWithEnum *>(union_obj));
- case Any_MyGame_Example2_Monster: return verifier.VerifyTable(reinterpret_cast<const MyGame::Example2::Monster *>(union_obj));
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
default: return false;
}
}
-inline flatbuffers::NativeTable *AnyUnion::UnPack(const void *union_obj, Any type, const flatbuffers::resolver_function_t *resolver) {
+inline flatbuffers::NativeTable *AnyUnion::UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver) {
switch (type) {
- case Any_NONE: return nullptr;
- case Any_Monster: return reinterpret_cast<const Monster *>(union_obj)->UnPack(resolver);
- case Any_TestSimpleTableWithEnum: return reinterpret_cast<const TestSimpleTableWithEnum *>(union_obj)->UnPack(resolver);
- case Any_MyGame_Example2_Monster: return reinterpret_cast<const MyGame::Example2::Monster *>(union_obj)->UnPack(resolver);
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
default: return nullptr;
}
}
-inline flatbuffers::Offset<void> AnyUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *rehasher) const {
+inline flatbuffers::Offset<void> AnyUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
switch (type) {
- case Any_NONE: return 0;
- case Any_Monster: return CreateMonster(_fbb, reinterpret_cast<const MonsterT *>(table), rehasher).Union();
- case Any_TestSimpleTableWithEnum: return CreateTestSimpleTableWithEnum(_fbb, reinterpret_cast<const TestSimpleTableWithEnumT *>(table), rehasher).Union();
- case Any_MyGame_Example2_Monster: return CreateMonster(_fbb, reinterpret_cast<const MyGame::Example2::MonsterT *>(table), rehasher).Union();
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MonsterT *>(table);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const TestSimpleTableWithEnumT *>(table);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(table);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
default: return 0;
}
}
inline void AnyUnion::Reset() {
switch (type) {
- case Any_Monster: delete reinterpret_cast<MonsterT *>(table); break;
- case Any_TestSimpleTableWithEnum: delete reinterpret_cast<TestSimpleTableWithEnumT *>(table); break;
- case Any_MyGame_Example2_Monster: delete reinterpret_cast<MyGame::Example2::MonsterT *>(table); break;
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<MonsterT *>(table);
+ delete ptr;
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<TestSimpleTableWithEnumT *>(table);
+ delete ptr;
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(table);
+ delete ptr;
+ break;
+ }
default: break;
}
table = nullptr;
@@ -887,10 +1210,12 @@ inline const char *MonsterIdentifier() {
}
inline bool MonsterBufferHasIdentifier(const void *buf) {
- return flatbuffers::BufferHasIdentifier(buf, MonsterIdentifier());
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier());
}
-inline bool VerifyMonsterBuffer(flatbuffers::Verifier &verifier) {
+inline bool VerifyMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<MyGame::Example::Monster>(MonsterIdentifier());
}
@@ -898,12 +1223,16 @@ inline const char *MonsterExtension() {
return "mon";
}
-inline void FinishMonsterBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<MyGame::Example::Monster> root) {
+inline void FinishMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
fbb.Finish(root, MonsterIdentifier());
}
-inline std::unique_ptr<MonsterT> UnPackMonster(const void *buf, const flatbuffers::resolver_function_t *resolver = nullptr) {
- return std::unique_ptr<MonsterT>(GetMonster(buf)->UnPack(resolver));
+inline std::unique_ptr<MonsterT> UnPackMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return std::unique_ptr<MonsterT>(GetMonster(buf)->UnPack(res));
}
} // namespace Example
diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h
index 3e036694..9c8c28a7 100644
--- a/tests/namespace_test/namespace_test1_generated.h
+++ b/tests/namespace_test/namespace_test1_generated.h
@@ -1,5 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
+
#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
#define FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
@@ -21,11 +22,19 @@ enum EnumInNestedNS {
};
inline const char **EnumNamesEnumInNestedNS() {
- static const char *names[] = { "A", "B", "C", nullptr };
+ static const char *names[] = {
+ "A",
+ "B",
+ "C",
+ nullptr
+ };
return names;
}
-inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) { return EnumNamesEnumInNestedNS()[static_cast<int>(e)]; }
+inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) {
+ const size_t index = static_cast<int>(e);
+ return EnumNamesEnumInNestedNS()[index];
+}
MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS {
private:
@@ -33,15 +42,28 @@ MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS {
int32_t b_;
public:
- StructInNestedNS() { memset(this, 0, sizeof(StructInNestedNS)); }
- StructInNestedNS(const StructInNestedNS &_o) { memcpy(this, &_o, sizeof(StructInNestedNS)); }
+ StructInNestedNS() {
+ memset(this, 0, sizeof(StructInNestedNS));
+ }
+ StructInNestedNS(const StructInNestedNS &_o) {
+ memcpy(this, &_o, sizeof(StructInNestedNS));
+ }
StructInNestedNS(int32_t _a, int32_t _b)
- : a_(flatbuffers::EndianScalar(_a)), b_(flatbuffers::EndianScalar(_b)) { }
-
- int32_t a() const { return flatbuffers::EndianScalar(a_); }
- void mutate_a(int32_t _a) { flatbuffers::WriteScalar(&a_, _a); }
- int32_t b() const { return flatbuffers::EndianScalar(b_); }
- void mutate_b(int32_t _b) { flatbuffers::WriteScalar(&b_, _b); }
+ : a_(flatbuffers::EndianScalar(_a)),
+ b_(flatbuffers::EndianScalar(_b)) {
+ }
+ int32_t a() const {
+ return flatbuffers::EndianScalar(a_);
+ }
+ void mutate_a(int32_t _a) {
+ flatbuffers::WriteScalar(&a_, _a);
+ }
+ int32_t b() const {
+ return flatbuffers::EndianScalar(b_);
+ }
+ void mutate_b(int32_t _b) {
+ flatbuffers::WriteScalar(&b_, _b);
+ }
};
STRUCT_END(StructInNestedNS, 8);
@@ -49,8 +71,12 @@ struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
enum {
VT_FOO = 4
};
- int32_t foo() const { return GetField<int32_t>(VT_FOO, 0); }
- bool mutate_foo(int32_t _foo) { return SetField(VT_FOO, _foo); }
+ int32_t foo() const {
+ return GetField<int32_t>(VT_FOO, 0);
+ }
+ bool mutate_foo(int32_t _foo) {
+ return SetField(VT_FOO, _foo);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int32_t>(verifier, VT_FOO) &&
@@ -64,15 +90,20 @@ struct TableInNestedNSBuilder {
void add_foo(int32_t foo) {
fbb_.AddElement<int32_t>(TableInNestedNS::VT_FOO, foo, 0);
}
- TableInNestedNSBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ TableInNestedNSBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
TableInNestedNSBuilder &operator=(const TableInNestedNSBuilder &);
flatbuffers::Offset<TableInNestedNS> Finish() {
- auto o = flatbuffers::Offset<TableInNestedNS>(fbb_.EndTable(start_, 1));
+ const auto end = fbb_.EndTable(start_, 1);
+ auto o = flatbuffers::Offset<TableInNestedNS>(end);
return o;
}
};
-inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(
+ flatbuffers::FlatBufferBuilder &_fbb,
int32_t foo = 0) {
TableInNestedNSBuilder builder_(_fbb);
builder_.add_foo(foo);
diff --git a/tests/namespace_test/namespace_test2_generated.h b/tests/namespace_test/namespace_test2_generated.h
index 693d9f83..15971ba1 100644
--- a/tests/namespace_test/namespace_test2_generated.h
+++ b/tests/namespace_test/namespace_test2_generated.h
@@ -1,5 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
+
#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
#define FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
@@ -29,12 +30,24 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_FOO_ENUM = 6,
VT_FOO_STRUCT = 8
};
- const NamespaceA::NamespaceB::TableInNestedNS *foo_table() const { return GetPointer<const NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE); }
- NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_table() { return GetPointer<NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE); }
- NamespaceA::NamespaceB::EnumInNestedNS foo_enum() const { return static_cast<NamespaceA::NamespaceB::EnumInNestedNS>(GetField<int8_t>(VT_FOO_ENUM, 0)); }
- bool mutate_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS _foo_enum) { return SetField(VT_FOO_ENUM, static_cast<int8_t>(_foo_enum)); }
- const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const { return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT); }
- NamespaceA::NamespaceB::StructInNestedNS *mutable_foo_struct() { return GetStruct<NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT); }
+ const NamespaceA::NamespaceB::TableInNestedNS *foo_table() const {
+ return GetPointer<const NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE);
+ }
+ NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_table() {
+ return GetPointer<NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE);
+ }
+ NamespaceA::NamespaceB::EnumInNestedNS foo_enum() const {
+ return static_cast<NamespaceA::NamespaceB::EnumInNestedNS>(GetField<int8_t>(VT_FOO_ENUM, 0));
+ }
+ bool mutate_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS _foo_enum) {
+ return SetField(VT_FOO_ENUM, static_cast<int8_t>(_foo_enum));
+ }
+ const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const {
+ return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
+ }
+ NamespaceA::NamespaceB::StructInNestedNS *mutable_foo_struct() {
+ return GetStruct<NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, VT_FOO_TABLE) &&
@@ -57,15 +70,20 @@ struct TableInFirstNSBuilder {
void add_foo_struct(const NamespaceA::NamespaceB::StructInNestedNS *foo_struct) {
fbb_.AddStruct(TableInFirstNS::VT_FOO_STRUCT, foo_struct);
}
- TableInFirstNSBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ TableInFirstNSBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
TableInFirstNSBuilder &operator=(const TableInFirstNSBuilder &);
flatbuffers::Offset<TableInFirstNS> Finish() {
- auto o = flatbuffers::Offset<TableInFirstNS>(fbb_.EndTable(start_, 3));
+ const auto end = fbb_.EndTable(start_, 3);
+ auto o = flatbuffers::Offset<TableInFirstNS>(end);
return o;
}
};
-inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(
+ flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0,
NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A,
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = 0) {
@@ -85,10 +103,18 @@ struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_REFER_TO_A1 = 4,
VT_REFER_TO_A2 = 6
};
- const NamespaceA::TableInFirstNS *refer_to_a1() const { return GetPointer<const NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1); }
- NamespaceA::TableInFirstNS *mutable_refer_to_a1() { return GetPointer<NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1); }
- const NamespaceA::SecondTableInA *refer_to_a2() const { return GetPointer<const NamespaceA::SecondTableInA *>(VT_REFER_TO_A2); }
- NamespaceA::SecondTableInA *mutable_refer_to_a2() { return GetPointer<NamespaceA::SecondTableInA *>(VT_REFER_TO_A2); }
+ const NamespaceA::TableInFirstNS *refer_to_a1() const {
+ return GetPointer<const NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1);
+ }
+ NamespaceA::TableInFirstNS *mutable_refer_to_a1() {
+ return GetPointer<NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1);
+ }
+ const NamespaceA::SecondTableInA *refer_to_a2() const {
+ return GetPointer<const NamespaceA::SecondTableInA *>(VT_REFER_TO_A2);
+ }
+ NamespaceA::SecondTableInA *mutable_refer_to_a2() {
+ return GetPointer<NamespaceA::SecondTableInA *>(VT_REFER_TO_A2);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, VT_REFER_TO_A1) &&
@@ -108,15 +134,20 @@ struct TableInCBuilder {
void add_refer_to_a2(flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2) {
fbb_.AddOffset(TableInC::VT_REFER_TO_A2, refer_to_a2);
}
- TableInCBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ TableInCBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
TableInCBuilder &operator=(const TableInCBuilder &);
flatbuffers::Offset<TableInC> Finish() {
- auto o = flatbuffers::Offset<TableInC>(fbb_.EndTable(start_, 2));
+ const auto end = fbb_.EndTable(start_, 2);
+ auto o = flatbuffers::Offset<TableInC>(end);
return o;
}
};
-inline flatbuffers::Offset<TableInC> CreateTableInC(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<TableInC> CreateTableInC(
+ flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1 = 0,
flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2 = 0) {
TableInCBuilder builder_(_fbb);
@@ -133,8 +164,12 @@ struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
enum {
VT_REFER_TO_C = 4
};
- const NamespaceC::TableInC *refer_to_c() const { return GetPointer<const NamespaceC::TableInC *>(VT_REFER_TO_C); }
- NamespaceC::TableInC *mutable_refer_to_c() { return GetPointer<NamespaceC::TableInC *>(VT_REFER_TO_C); }
+ const NamespaceC::TableInC *refer_to_c() const {
+ return GetPointer<const NamespaceC::TableInC *>(VT_REFER_TO_C);
+ }
+ NamespaceC::TableInC *mutable_refer_to_c() {
+ return GetPointer<NamespaceC::TableInC *>(VT_REFER_TO_C);
+ }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, VT_REFER_TO_C) &&
@@ -149,15 +184,20 @@ struct SecondTableInABuilder {
void add_refer_to_c(flatbuffers::Offset<NamespaceC::TableInC> refer_to_c) {
fbb_.AddOffset(SecondTableInA::VT_REFER_TO_C, refer_to_c);
}
- SecondTableInABuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
+ SecondTableInABuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
SecondTableInABuilder &operator=(const SecondTableInABuilder &);
flatbuffers::Offset<SecondTableInA> Finish() {
- auto o = flatbuffers::Offset<SecondTableInA>(fbb_.EndTable(start_, 1));
+ const auto end = fbb_.EndTable(start_, 1);
+ auto o = flatbuffers::Offset<SecondTableInA>(end);
return o;
}
};
-inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(flatbuffers::FlatBufferBuilder &_fbb,
+inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(
+ flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<NamespaceC::TableInC> refer_to_c = 0) {
SecondTableInABuilder builder_(_fbb);
builder_.add_refer_to_c(refer_to_c);