mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 13:08:58 +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
@@ -365,6 +365,12 @@ std::string TextFileName(const std::string &path,
|
||||
|
||||
bool GenerateTextFile(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
if (parser.opts.use_flexbuffers) {
|
||||
std::string json;
|
||||
parser.flex_root_.ToString(true, parser.opts.strict_json, json);
|
||||
return flatbuffers::SaveFile(TextFileName(path, file_name).c_str(),
|
||||
json.c_str(), json.size(), true);
|
||||
}
|
||||
if (!parser.builder_.GetSize() || !parser.root_struct_def_) return true;
|
||||
std::string text;
|
||||
if (!GenerateText(parser, parser.builder_.GetBufferPointer(), &text)) {
|
||||
|
||||
Reference in New Issue
Block a user