|
Boost Users : |
Subject: Re: [Boost-users] [iostreams] Problem with gzip_decompressor
From: Brian Budge (brian.budge_at_[hidden])
Date: 2010-11-10 11:33:07
Yeah, I was awfully confused at first too. In the code I've got
working, I use filtering_ostream for both compression and
decompression, and use a back_inserter like this:
vector<char> comp;
bio::filtering_ostream cStream;
cStream.push(bio::zlib_compressor() | bio::back_inserter(comp));
cStream.write(decompressedMemory, decompressedSize);
vector<char> decomp;
bio::filtering_ostream dStream;
dStream.push(bio::zlib_decompressor() | bio::back_inserter(decomp));
dStream.write(&comp[0], comp.size());
bio::close(dStream);
Brian
On Wed, Nov 10, 2010 at 12:42 AM, é³éä»» <chenwj_at_[hidden]> wrote:
> Dear all,
>
> Â Some compressed data was stored in a vector<char> buf (don't know if it's
> a right way to store compressed data). I used the "buf" as a source, and
> tried to add a gzip_decompressor to restore those data. I have tried the
> following approach, but it doesn't work.
>
> Â vector<char> buf;
>
> Â /* fill in the buf */
>
> Â namespace io = boost::iostreams;
> Â io::filtering_istream in(boost::make_iterator_range(buf));
> Â in.push(io::gzip_decompressor());
>
> What I got is an exception,
>
> Â terminate called after throwing an instance of
> Â 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector
> Â <std::logic_error>>'
> Â what(): Â chain complete
> Â Aborted
>
> Â How can I compose a source which comes from a container, and add a
> gzip_decompressor to the source? Thanks in advance.
>
> Regards,
> chenwj
>
> --
> Wei-Jen Chen (é³éä»»)
> Programming Language and System Laboratory (EC131)
> Department of Computer Science, National Chiao Tung University
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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