On Wed, Jan 30, 2013 at 12:45 PM, David Granados <deivi...@gmail.com> wrote:

>
>
If i write the size and is 192, compress does not work.
>

In the code you attached, you are writing the *uncompressed* size to cout:

  std::cout << gzip_stream.ByteCount()<<std::endl;


GzipOutputStream::ByteCount() returns the number of uncompressed bytes
written *to* the stream, not the number of compressed bytes that were
written to the underlying stream. If you want to count the compressed
bytes, call ByteCount() on the underlying stream. (i.e. output->ByteCount()
in your code)

Also, if you want to eventually end up with a std::string containing the
compressed output, why don't you use StringOutputStream? Something like
this (untested):

  {
    StringOutputStream compressedStream(&outputString);
    GzipOutputStream compressingStream(compressedStream, options);
    pProto.SerializeToZeroCopyStream(&compressingStream); // error checks
omitted for brevity
    // let destructors do stream cleanup
  }

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to