Boost logo

Boost Users :

From: eg (egoots_at_[hidden])
Date: 2006-12-07 01:48:41


Maurice van Swaaij wrote:
> Hi,
>
> Is there a way to set a filtering_stream to binary mode so I can use its
> operator>> and operator<< to read and write binary data?
>
> Thanks.
>
I use ios_base::binary when I open the stream. Search the old newsgroup
messages... there was some caution made about using << and >> with
binary data. The recommendation was to use read and write instead.

   namespace io = boost::iostreams;

   io::filtering_ostream out;
   out.push(io::gzip_compressor());
   out.push( io::file_sink("my_file.gz",
             ios_base::out | ios_base::binary));

NOW you can write to out


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net