Boost logo

Boost Users :

From: Jonathan Turkanis (turkanis_at_[hidden])
Date: 2008-01-18 18:31:56


Marc Viala Perso wrote:
> Hello,
>
> I'm just wondering why zlib and bzip2 codec are "dual_use" filter but not
> gzip? Can anybody enlighten me on this restriction?

Yeah, I'm probably the only one who can enlighten you. It was sheer
laziness on my part, because the implementation looked like it would be
pretty messy and I thought it would typically be used with input
streams. There's no good excuse for this -- sorry. I've created a ticket
to fix it for 1.36 (http://svn.boost.org/trac/boost/ticket/1579). It's
too late for 1.35, but I may post a patch.

> In fact, I have the following use case:

...

> class gzfstream: public
> boost::iostreams::filtering_stream<boost::iostreams::dual_use>

You should never instantiate a
filtering_stream<boost::iostreams::dual_use>. DualUse is not a real
mode, it's a pseudo mode, provided as a convenience for filter
implementors. I should put in a STATIC_ASSERT somewhere to prevent this.

If you need to use an external interface that expects an iostream, you
could use a filtering_stream<bidirectional>, together with
boost::iostreams::combination (http://tinyurl.com/24zwqy) to producing a
bidirectional filter. Depending on your use case, which I don't fully
understand, you could combine two compression filters to produce a
bidirectional compression filter, or a compression filter with a dummy
filter that always throws, to produce a bidirectional stream that at
runtime can only be used for unidirectional i/o.

If you need to use a gzip_decompressor for output, you should be able to
use

        boost::iostreams::inverse<gzip_decompressor>.

(See http://tinyurl.com/2e5dxh.) Let me know if this doesn't work.

> Best regards,
>
> Marc VIALA

-- 
Jonathan Turkanis
CodeRage
http://www.coderage.com

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