mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-15 00:38:52 +00:00
Fixed spaces. Removed redundant == nullptr. Vectors pointers made const.
This commit is contained in:
@@ -458,7 +458,7 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
void GenSimpleParam(std::string &code, FieldDef &field) {
|
||||
code += ",\n " + GenTypeWire(field.value.type, " ", true);
|
||||
code += ",\n " + GenTypeWire(field.value.type, " ", true);
|
||||
code += field.name + " = ";
|
||||
if (field.value.type.enum_def && IsScalar(field.value.type.base_type)) {
|
||||
auto ev = field.value.type.enum_def->ReverseLookup(
|
||||
@@ -742,11 +742,11 @@ class CppGenerator : public BaseGenerator {
|
||||
auto &field = **it;
|
||||
if (!field.deprecated) {
|
||||
if (field.value.type.base_type == BASE_TYPE_STRING) {
|
||||
code += ",\n const char *";
|
||||
code += ",\n const char *";
|
||||
code += field.name + " = nullptr";
|
||||
}
|
||||
else if (field.value.type.base_type == BASE_TYPE_VECTOR) {
|
||||
code += ",\n std::vector<";
|
||||
code += ",\n const std::vector<";
|
||||
code += GenTypeWire(field.value.type.VectorType(), "", false);
|
||||
code += "> *" + field.name + " = nullptr";
|
||||
} else {
|
||||
@@ -755,7 +755,6 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
code += ") {\n ";
|
||||
|
||||
code += "return Create";
|
||||
code += struct_def.name;
|
||||
code += "(_fbb";
|
||||
@@ -764,18 +763,16 @@ class CppGenerator : public BaseGenerator {
|
||||
auto &field = **it;
|
||||
if (!field.deprecated) {
|
||||
if (field.value.type.base_type == BASE_TYPE_STRING) {
|
||||
code += ", " + field.name + " == nullptr ? 0 : ";
|
||||
code += ", " + field.name + " ? 0 : ";
|
||||
code += "_fbb.CreateString(" + field.name + ")";
|
||||
} else if (field.value.type.base_type == BASE_TYPE_VECTOR) {
|
||||
code += ", " + field.name + " == nullptr ? 0 : ";
|
||||
code += ", " + field.name + " ? 0 : ";
|
||||
code += "_fbb.CreateVector<";
|
||||
code += GenTypeWire(field.value.type.VectorType(), "", false);
|
||||
code += ">(*" + field.name + ")";
|
||||
} else code += ", " + field.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
code += ");\n}\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ struct TestSimpleTableWithEnumBuilder {
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
Color color = Color_Green) {
|
||||
Color color = Color_Green) {
|
||||
TestSimpleTableWithEnumBuilder builder_(_fbb);
|
||||
builder_.add_color(color);
|
||||
return builder_.Finish();
|
||||
@@ -205,9 +205,9 @@ struct StatBuilder {
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> id = 0,
|
||||
int64_t val = 0,
|
||||
uint16_t count = 0) {
|
||||
flatbuffers::Offset<flatbuffers::String> id = 0,
|
||||
int64_t val = 0,
|
||||
uint16_t count = 0) {
|
||||
StatBuilder builder_(_fbb);
|
||||
builder_.add_val(val);
|
||||
builder_.add_id(id);
|
||||
@@ -216,10 +216,10 @@ inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *id = nullptr,
|
||||
int64_t val = 0,
|
||||
uint16_t count = 0) {
|
||||
return CreateStat(_fbb, id == nullptr ? 0 : _fbb.CreateString(id), val, count);
|
||||
const char *id = nullptr,
|
||||
int64_t val = 0,
|
||||
uint16_t count = 0) {
|
||||
return CreateStat(_fbb, id ? 0 : _fbb.CreateString(id), val, count);
|
||||
}
|
||||
|
||||
/// an example documentation comment: monster object
|
||||
@@ -404,34 +404,34 @@ struct MonsterBuilder {
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const Vec3 *pos = 0,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
|
||||
Color color = Color_Blue,
|
||||
Any test_type = Any_NONE,
|
||||
flatbuffers::Offset<void> test = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4 = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Monster>>> testarrayoftables = 0,
|
||||
flatbuffers::Offset<Monster> enemy = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
|
||||
flatbuffers::Offset<Stat> testempty = 0,
|
||||
bool testbool = false,
|
||||
int32_t testhashs32_fnv1 = 0,
|
||||
uint32_t testhashu32_fnv1 = 0,
|
||||
int64_t testhashs64_fnv1 = 0,
|
||||
uint64_t testhashu64_fnv1 = 0,
|
||||
int32_t testhashs32_fnv1a = 0,
|
||||
uint32_t testhashu32_fnv1a = 0,
|
||||
int64_t testhashs64_fnv1a = 0,
|
||||
uint64_t testhashu64_fnv1a = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
|
||||
float testf = 3.14159f,
|
||||
float testf2 = 3.0f,
|
||||
float testf3 = 0.0f,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0) {
|
||||
const Vec3 *pos = 0,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
|
||||
Color color = Color_Blue,
|
||||
Any test_type = Any_NONE,
|
||||
flatbuffers::Offset<void> test = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Test *>> test4 = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Monster>>> testarrayoftables = 0,
|
||||
flatbuffers::Offset<Monster> enemy = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
|
||||
flatbuffers::Offset<Stat> testempty = 0,
|
||||
bool testbool = false,
|
||||
int32_t testhashs32_fnv1 = 0,
|
||||
uint32_t testhashu32_fnv1 = 0,
|
||||
int64_t testhashs64_fnv1 = 0,
|
||||
uint64_t testhashu64_fnv1 = 0,
|
||||
int32_t testhashs32_fnv1a = 0,
|
||||
uint32_t testhashu32_fnv1a = 0,
|
||||
int64_t testhashs64_fnv1a = 0,
|
||||
uint64_t testhashu64_fnv1a = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
|
||||
float testf = 3.14159f,
|
||||
float testf2 = 3.0f,
|
||||
float testf3 = 0.0f,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_testhashu64_fnv1a(testhashu64_fnv1a);
|
||||
builder_.add_testhashs64_fnv1a(testhashs64_fnv1a);
|
||||
@@ -465,35 +465,35 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const Vec3 *pos = 0,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
const char *name = nullptr,
|
||||
std::vector<uint8_t> *inventory = nullptr,
|
||||
Color color = Color_Blue,
|
||||
Any test_type = Any_NONE,
|
||||
flatbuffers::Offset<void> test = 0,
|
||||
std::vector<const Test *> *test4 = nullptr,
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring = nullptr,
|
||||
std::vector<flatbuffers::Offset<Monster>> *testarrayoftables = nullptr,
|
||||
flatbuffers::Offset<Monster> enemy = 0,
|
||||
std::vector<uint8_t> *testnestedflatbuffer = nullptr,
|
||||
flatbuffers::Offset<Stat> testempty = 0,
|
||||
bool testbool = false,
|
||||
int32_t testhashs32_fnv1 = 0,
|
||||
uint32_t testhashu32_fnv1 = 0,
|
||||
int64_t testhashs64_fnv1 = 0,
|
||||
uint64_t testhashu64_fnv1 = 0,
|
||||
int32_t testhashs32_fnv1a = 0,
|
||||
uint32_t testhashu32_fnv1a = 0,
|
||||
int64_t testhashs64_fnv1a = 0,
|
||||
uint64_t testhashu64_fnv1a = 0,
|
||||
std::vector<uint8_t> *testarrayofbools = nullptr,
|
||||
float testf = 3.14159f,
|
||||
float testf2 = 3.0f,
|
||||
float testf3 = 0.0f,
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr) {
|
||||
return CreateMonster(_fbb, pos, mana, hp, name == nullptr ? 0 : _fbb.CreateString(name), inventory == nullptr ? 0 : _fbb.CreateVector<uint8_t>(*inventory), color, test_type, test, test4 == nullptr ? 0 : _fbb.CreateVector<const Test *>(*test4), testarrayofstring == nullptr ? 0 : _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring), testarrayoftables == nullptr ? 0 : _fbb.CreateVector<flatbuffers::Offset<Monster>>(*testarrayoftables), enemy, testnestedflatbuffer == nullptr ? 0 : _fbb.CreateVector<uint8_t>(*testnestedflatbuffer), testempty, testbool, testhashs32_fnv1, testhashu32_fnv1, testhashs64_fnv1, testhashu64_fnv1, testhashs32_fnv1a, testhashu32_fnv1a, testhashs64_fnv1a, testhashu64_fnv1a, testarrayofbools == nullptr ? 0 : _fbb.CreateVector<uint8_t>(*testarrayofbools), testf, testf2, testf3, testarrayofstring2 == nullptr ? 0 : _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2));
|
||||
const Vec3 *pos = 0,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
const char *name = nullptr,
|
||||
const std::vector<uint8_t> *inventory = nullptr,
|
||||
Color color = Color_Blue,
|
||||
Any test_type = Any_NONE,
|
||||
flatbuffers::Offset<void> test = 0,
|
||||
const std::vector<const Test *> *test4 = nullptr,
|
||||
const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring = nullptr,
|
||||
const std::vector<flatbuffers::Offset<Monster>> *testarrayoftables = nullptr,
|
||||
flatbuffers::Offset<Monster> enemy = 0,
|
||||
const std::vector<uint8_t> *testnestedflatbuffer = nullptr,
|
||||
flatbuffers::Offset<Stat> testempty = 0,
|
||||
bool testbool = false,
|
||||
int32_t testhashs32_fnv1 = 0,
|
||||
uint32_t testhashu32_fnv1 = 0,
|
||||
int64_t testhashs64_fnv1 = 0,
|
||||
uint64_t testhashu64_fnv1 = 0,
|
||||
int32_t testhashs32_fnv1a = 0,
|
||||
uint32_t testhashu32_fnv1a = 0,
|
||||
int64_t testhashs64_fnv1a = 0,
|
||||
uint64_t testhashu64_fnv1a = 0,
|
||||
const std::vector<uint8_t> *testarrayofbools = nullptr,
|
||||
float testf = 3.14159f,
|
||||
float testf2 = 3.0f,
|
||||
float testf3 = 0.0f,
|
||||
const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr) {
|
||||
return CreateMonster(_fbb, pos, mana, hp, name ? 0 : _fbb.CreateString(name), inventory ? 0 : _fbb.CreateVector<uint8_t>(*inventory), color, test_type, test, test4 ? 0 : _fbb.CreateVector<const Test *>(*test4), testarrayofstring ? 0 : _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring), testarrayoftables ? 0 : _fbb.CreateVector<flatbuffers::Offset<Monster>>(*testarrayoftables), enemy, testnestedflatbuffer ? 0 : _fbb.CreateVector<uint8_t>(*testnestedflatbuffer), testempty, testbool, testhashs32_fnv1, testhashu32_fnv1, testhashs64_fnv1, testhashu64_fnv1, testhashs32_fnv1a, testhashu32_fnv1a, testhashs64_fnv1a, testhashu64_fnv1a, testarrayofbools ? 0 : _fbb.CreateVector<uint8_t>(*testarrayofbools), testf, testf2, testf3, testarrayofstring2 ? 0 : _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2));
|
||||
}
|
||||
|
||||
inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type) {
|
||||
|
||||
Reference in New Issue
Block a user