c++ - 如何使用 Boost 解压缩压缩数据的 vector ?

标签 c++ boost compression zlib boost-iostreams

我有一个包含 zlib 压缩(压缩)数据的 vector 。我想用 Boost 的 filtering_istream 解压缩它。他们的网站上只有一个示例,它对数据流进行操作(与我拥有的 vector 相反)。

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?

我也想将未压缩的数据作为 vector 获取。我该怎么做?

最佳答案

array_source 怎么样? ?

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

然后使用 boost::iostreams::copystd::insert_iterator 将结果字符插入新 vector 。

关于c++ - 如何使用 Boost 解压缩压缩数据的 vector ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9557555/

相关文章:

c++ - 如何使用 C++ 将 Boost ptree 插入 MongoDB

c++ - 我应该使用 boost::variant 吗?

c++ - 从 boost::adjacency_list 图中删除多个顶点

c# - .NET 压缩 XML 以存储在 SQL Server 数据库中

linux - 替代创建多部分 .tar.gz 文件?

c++ - 分配包含 STL vector 的结构时发生内存泄漏

c++ - 在 Visual Studio 中构建没有 C/C++ 运行时的静态库

php - 加速 ajax 请求 - 可以应用 gzip 压缩吗?

c++ - 如何在多个架构中将 ccache 与 gcc -march=native 一起使用?

c++ - 如何用ICU编译sqlite?