mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 05:27:24 +00:00
[flac] Add FlexBuffers option for generating data (#5519)
Alongside --binary and --json, an additional switch (--flexbuffers) can be passed to convert data using FlexBuffers
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
a92039687a
commit
cfb4ecf6f0
@@ -349,6 +349,12 @@ void AppendToString(std::string &s, T &&v, bool keys_quoted) {
|
||||
|
||||
class Reference {
|
||||
public:
|
||||
Reference()
|
||||
: data_(nullptr),
|
||||
parent_width_(0),
|
||||
byte_width_(BIT_WIDTH_8),
|
||||
type_(FBT_NULL) {}
|
||||
|
||||
Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width,
|
||||
Type type)
|
||||
: data_(data),
|
||||
|
||||
@@ -491,6 +491,8 @@ struct ServiceDef : public Definition {
|
||||
|
||||
// Container of options that may apply to any of the source/text generators.
|
||||
struct IDLOptions {
|
||||
// Use flexbuffers instead for binary and text generation
|
||||
bool use_flexbuffers;
|
||||
bool strict_json;
|
||||
bool skip_js_exports;
|
||||
bool use_goog_js_export_format;
|
||||
@@ -573,7 +575,8 @@ struct IDLOptions {
|
||||
bool set_empty_to_null;
|
||||
|
||||
IDLOptions()
|
||||
: strict_json(false),
|
||||
: use_flexbuffers(false),
|
||||
strict_json(false),
|
||||
skip_js_exports(false),
|
||||
use_goog_js_export_format(false),
|
||||
use_ES6_js_export_format(false),
|
||||
@@ -707,6 +710,7 @@ class Parser : public ParserState {
|
||||
explicit Parser(const IDLOptions &options = IDLOptions())
|
||||
: current_namespace_(nullptr),
|
||||
empty_namespace_(nullptr),
|
||||
flex_builder_(256, flexbuffers::BUILDER_FLAG_SHARE_ALL),
|
||||
root_struct_def_(nullptr),
|
||||
opts(options),
|
||||
uses_flexbuffers_(false),
|
||||
@@ -908,6 +912,8 @@ class Parser : public ParserState {
|
||||
std::string error_; // User readable error_ if Parse() == false
|
||||
|
||||
FlatBufferBuilder builder_; // any data contained in the file
|
||||
flexbuffers::Builder flex_builder_;
|
||||
flexbuffers::Reference flex_root_;
|
||||
StructDef *root_struct_def_;
|
||||
std::string file_identifier_;
|
||||
std::string file_extension_;
|
||||
|
||||
Reference in New Issue
Block a user