简体   繁体   English

使用boost :: iostreams :: filtering_streambuf解压缩zlib数据

[英]Uncompressing zlib data using boost::iostreams::filtering_streambuf trouble

I'm trying to write a small class that will load the chunk data from part of a minecraft world file. 我正在尝试编写一个小类,该类将从Minecraft世界文件的一部分加载块数据。 I'm to the point where I have stored some data in a char array which was compressed with zlib and need to decompress it. 我已经将一些数据存储在用zlib压缩的char数组中,需要对其进行解压缩。

I'm trying to use the boost filtering_streambuf to do this. 我正在尝试使用增强的filtering_streambuf来做到这一点。

char * rawChunk = new char[length - 1];

// Load chunk data


stringstream ssRawChunk(rawChunk);

boost::iostreams::filtering_istream in;

in.push(boost::iostreams::zlib_decompressor());
in.push(ssRawChunk);

stringstream ssOut;

boost::iostreams::copy(in, ssOut);

My problem is that rawChunk contains null data, so when coping data from (char*) rawChunk to (stringstream) ssRawChunk , it terminates at ~257 instead of the expected length 2154. 我的问题是rawChunk包含null数据,因此当将数据从(char*) rawChunk(stringstream) ssRawChunk ,它终止于(stringstream) ssRawChunk ,而不是预期的长度2154。

Is there any way to use filtering_streambuf without stringstream to allow for null data or is there a way to stop stringstream to not terminate on null data? 有没有办法在没有stringstream的情况下使用filtering_streambuf允许空数据,或者有没有办法停止stringstream不终止于空数据?

您应该将rawChunk存储到允许空字符的std::string中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加速 boost::iostreams::filtering_streambuf - Speeding up boost::iostreams::filtering_streambuf boost property_tree :: json_parser :: read_json&iostreams :: filtering_streambuf - boost property_tree::json_parser::read_json & iostreams::filtering_streambuf c++ boostfiltering_streambuf只读取一些数据 - c++ boost filtering_streambuf read only some data 将 boost::filtering_streambuf 与 newline_filter 一起使用时为空文件 - Empty file when using boost::filtering_streambuf with newline_filter 将文件从Boost filtering_streambuf解压缩到std :: vector <char> ? - Decompress file from Boost filtering_streambuf to std::vector<char>? 使用boost :: iostreams :: zlib_compressor为什么需要销毁boost :: iostream :: filtering_ostream才能写入接收器? - Why boost::iostream::filtering_ostream using boost::iostreams::zlib_compressor needs to be destroyed for the sink to be written? 将文件从Boost filter_streambuf解压缩到std :: vector <unsigned char> ? - Decompress file from Boost filtering_streambuf to std::vector<unsigned char>? 使用 zlib 构建 boost::iostreams - build boost::iostreams with zlib binary_oarchive 和 filtering_streambuf 的析构函数非常慢 - Very slow destructors of binary_oarchive and filtering_streambuf 使用boost :: archive和boost :: iostreams来压缩数据 - Using boost::archive with boost::iostreams to compress data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM