bool GenerateTextFile(const Parser &parser, const std::string &path, const std::string &file_name) { if (!parser.builder_.GetSize() || !parser.root_struct_def_) return true; std::string text; GenerateText(parser, parser.builder_.GetBufferPointer(), &text); return flatbuffers::SaveFile(TextFileName(path, file_name).c_str(), text, false); }
bool GenerateTextFile(const Parser &parser, const std::string &path, const std::string &file_name) { if (!parser.builder_.GetSize()) return true; if (!parser.root_struct_def) Error("root_type not set"); std::string text; GenerateText(parser, parser.builder_.GetBufferPointer(), 2, &text); return flatbuffers::SaveFile((path + file_name + "_wire.txt").c_str(), text, false); }
std::string deserializeJSON( const zeroeq::Event& event ) { const std::string& schema = getSchema( event.getType( )); if( schema.empty( )) ZEROEQTHROW( std::runtime_error( "JSON schema for event not registered" )); flatbuffers::Parser parser; if( !parser.Parse( schema.c_str( ))) ZEROEQTHROW( std::runtime_error( parser.error_ )); std::string json; flatbuffers::GeneratorOptions opts; opts.base64_byte_array = true; opts.strict_json = true; GenerateText( parser, event.getData(), opts, &json ); return json; }