You need to use the SerializeToZeroCopyStream interface, since you want to
pass in a custom stream. You use GzipOutputStream just like any other
ZeroCopyOutputStream, except it needs to wrap the underlying stream
implementation. Since you mention writing to a gzip file, you might do
something like:

int fd = ...;
FileOutputStream file_stream(fd);
GZipOutputStream gzip_stream(&file_stream, GzipOutputStream::Options());
msg.SerializeToZeroCopyStream(&gzip_stream);

On Mon, Oct 3, 2011 at 3:07 PM, Luke <lkrec...@googlemail.com> wrote:

> Dear all,
>
> after some days of experimenting with Protocol Buffers I tried to
> compress the files.
> With Python this is quite simple to do and does not require any play
> with streams.
>
> Since most of our code is written in C++ I would like to compress/
> decompress files in the same language.
> I've searched for examples utilising GzipOutputStream and
> GzipInputStream with Protocol Buffers but could not find a working
> example.
> As you probably noticed by now I am a beginner at best with streams
> and would really appreciate a fully working example as in
> http://code.google.com/apis/protocolbuffers/docs/cpptutorial.html
> (I have my address_book, how do I save it in a gziped file?)
>
> Thank you in advance.
>
> Cheers,
> Luke
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@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.

Reply via email to