VisualC++在内存中解压
我有一个“stringstream”变量,它以 gzip 格式存储一些压缩的二进制数据。
我想在内存中解压缩这个字符串流变量。
首先,对于gzip格式的二进制数据的内存解压,您建议使用什么第三方库?
我注意到 zlib 库用于 gzip 和 deflate 格式的压缩/解压缩。
然而,zlip提供的两个处理解压缩的函数似乎并不能完全满足我的需求:
int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
int gzread (gzFile file, voidp buf, unsigned len);
第一个(uncompress)需要我提前知道解压数据的长度,以便正确分配足够的内存进行存储。就我而言,这是未知的。
另一方面,第二个(gzread)将文件作为输入,而不是内存缓冲区。
对于使用 zlip 或其他库进行“高效”内存解压缩,您有什么建议?
谢谢。
I have a "stringstream" variable that stores some compressed binary data in gzip format.
I want to decompress this stringstream variable in memory.
First of all, for in-memory decompression of binary data in gzip format, what third party library do you suggest to use ?
I noticed zlib library for compression/decompression of gzip and deflate formats.
However, the two functions handling decompression that zlip provides do not seem to meet my needs exactly:
int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
int gzread (gzFile file, voidp buf, unsigned len);
The first one (uncompress) requires me to know the length of the decompressed data in advance to properly allocate enough memory for storage. In my case, it is unknown.
On the other hand, the second one (gzread) takes a file as input, not a memory buffer.
What do you suggest for an "efficient" in-memory decompression using zlip or some other library ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Boost 库中似乎有一些用于 gzip 的解压缩过滤器,这可能值得研究一下:
http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/gzip.html
There appears to be some decompression filters for gzip in the Boost library, this might be worth looking into:
http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/gzip.html