iostream 到 zlib 和 C++ 文件?
.NET 宠坏了我,让我意识到某些事情可以多么简单:(
对于 C++,我想使用 fopen 或 ostream/istream 将数据直接推送到 zlib 或某种内存缓冲区(然后是 zlib),然后继续将其转储到文件中。我想要类似的东西将其加载回来。
我查看了 zlibs 示例,虽然它看起来很简单,但它不是 iostream 或文件,我需要使用缓冲区。有谁知道现有的解决方案。 ?
.NET has spoiled me and made me realize how simple certain things can be :(
With C++ i'd like to use either fopen or ostream/istream to push data to either zlib directly or to some kind of memory buffer (then zlib) then proceed to dump it to a file. I'd like something similar to load it back in.
I looked at zlibs example and while it looks simple it isnt an iostream or file and i need to use buffers. Does anyone know of a existing solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 boost IOstream API 来读取压缩文件并创建 iostream。我根据 Boost 文档为此编写了代码。有关如何逐行读取压缩文件的代码和相关问题可在此处找到:
如何使用 Boost IOStreams 接口逐行读取 Gzip 文件?
You need to use boost IOstream API to read the zipped files and create an iostream. I wrote code for this based on Boost documentation. The code and a related question on how to read the zipped file line -by-line is available here:
How can I read line-by-line using Boost IOStreams' interface for Gzip files?