如何使用Boost解压缩放气数据的向量?

时间:2012-03-04 18:18:02

标签: c++ boost compression zlib boost-iostreams

我有一个包含zlib压缩(放气)数据的向量。我想用Boost的filtering_istream解压缩它。他们的网站上只有一个例子,它运行在一个数据流上(而不是我拥有的矢量)。

vector<char> compressed_buffer;
compressed_buffer.resize(cdh.length);
file.read(&compressed_buffer[0], cdh.length);

filtering_istream in;
in.push(zlib_decompressor());
in.push(something(compressed_data)); // what should "something" be?

我想将未压缩的数据作为矢量获取。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

array_source怎么样?

in.push(array_source(&*compressed_data.begin(), &*compressed_data.end()));

然后使用boost::iostreams::copystd::insert_iterator将结果字符推送到新的向量中。