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_streamboost::iostreams::dual_use
You should never instantiate a
filtering_streamboost::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
Best regards,
Marc VIALA
-- Jonathan Turkanis CodeRage http://www.coderage.com