Hello all ! I am trying to save multiple Protocol Buffer messages into a file and then reading them back. All messages (except the first) have the same type.
My code now works. But I had to use a workaround instead. The code looks as follows. boost::uint64_t size; const bool read_size_success = input_coded_stream_p->ReadLittleEndian64(&size); bool read_data_success = false; const bool use_zero_copy_stream = false; if(use_zero_copy_stream) { read_data_success = data.ParseFromBoundedZeroCopyStream(input_stream_p.get(), static_cast<int>(size)); } else { // work around std::string buffer; input_coded_stream_p->ReadString(&buffer, size); read_data_success = data.ParseFromString(buffer); } if (read_size_success == false or read_data_success == false) { throw std::runtime_error("Failed to read a data message during DataSequence<DataType>::read"); } The code above works fine when using use_zero_copy_stream == false however when I set use_zero_copy_stream to true then the read fails (read_data_success == false). Obviously input_coded_stream_p was constructed using input_stream_p. Why is ParseFromBoundedZeroCopyStream not working as expected ? What is the proper way of using it ? Thanks for your answers. Best regards, rodrigob. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.