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
@@ -1782,6 +1782,14 @@ std::string BinaryFileName(const Parser &parser, const std::string &path,
|
||||
|
||||
bool GenerateBinary(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
if (parser.opts.use_flexbuffers) {
|
||||
auto data_vec = parser.flex_builder_.GetBuffer();
|
||||
auto data_ptr = reinterpret_cast<char *>(data_vec.data());
|
||||
return !parser.flex_builder_.GetSize() ||
|
||||
flatbuffers::SaveFile(
|
||||
BinaryFileName(parser, path, file_name).c_str(), data_ptr,
|
||||
parser.flex_builder_.GetSize(), true);
|
||||
}
|
||||
return !parser.builder_.GetSize() ||
|
||||
flatbuffers::SaveFile(
|
||||
BinaryFileName(parser, path, file_name).c_str(),
|
||||
|
||||
Reference in New Issue
Block a user