mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 06:30:54 +00:00
Allow structs to be parsed in JSON with out of order fields.
Also simplified the code and made it faster. Change-Id: I1d83b1165a4a9a4380d1bfb5538769c012d2d367 Tested: on Linux.
This commit is contained in:
@@ -221,8 +221,7 @@ struct Definition {
|
||||
};
|
||||
|
||||
struct FieldDef : public Definition {
|
||||
FieldDef() : deprecated(false), required(false), key(false), padding(0),
|
||||
used(false) {}
|
||||
FieldDef() : deprecated(false), required(false), key(false), padding(0) {}
|
||||
|
||||
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id)
|
||||
const;
|
||||
@@ -233,7 +232,6 @@ struct FieldDef : public Definition {
|
||||
bool required; // Field must always be present.
|
||||
bool key; // Field functions as a key for creating sorted vectors.
|
||||
size_t padding; // Bytes to always pad after this field.
|
||||
bool used; // Used during JSON parsing to check for repeated fields.
|
||||
};
|
||||
|
||||
struct StructDef : public Definition {
|
||||
@@ -378,8 +376,8 @@ class Parser {
|
||||
const std::string &name,
|
||||
const Type &type);
|
||||
void ParseField(StructDef &struct_def);
|
||||
void ParseAnyValue(Value &val, FieldDef *field);
|
||||
uoffset_t ParseTable(const StructDef &struct_def);
|
||||
void ParseAnyValue(Value &val, FieldDef *field, size_t parent_fieldn);
|
||||
uoffset_t ParseTable(const StructDef &struct_def, std::string *value);
|
||||
void SerializeStruct(const StructDef &struct_def, const Value &val);
|
||||
void AddVector(bool sortbysize, int count);
|
||||
uoffset_t ParseVector(const Type &type);
|
||||
@@ -428,7 +426,6 @@ class Parser {
|
||||
std::vector<std::string> doc_comment_;
|
||||
|
||||
std::vector<std::pair<Value, FieldDef *>> field_stack_;
|
||||
std::vector<uint8_t> struct_stack_;
|
||||
|
||||
std::set<std::string> known_attributes_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user