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
int fd = ...;
GZipOutputStream gzip_stream(&file_stream, GzipOutputStream::Options());
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
> As you probably noticed by now I am a beginner at best with streams
> and would really appreciate a fully working example as in
> (I have my address_book, how do I save it in a gziped file?)
> Thank you in advance.
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to email@example.com.
> To unsubscribe from this group, send email to
> For more options, visit this group at
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to
For more options, visit this group at