C++ 有哪些简单的 zlib 教程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5362250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:59:42  来源:igfitidea点击:

What easy zlib tutorials are there?

c++czlib

提问by Paul Manta

I'm looking for a good tutorial on zlib. I'm interested only in decompressing the archives. I also want to know how I can access a desired file inside an archive, preferably by filename alone, if that can be done in zlib at all.

我正在寻找关于 zlib 的好教程。我只对解压缩档案感兴趣。我还想知道如何访问存档中所需的文件,最好仅通过文件名访问,如果这可以在 zlib 中完成的话。

回答by Muhammad Shahab

Well there are many zlib articles , tips and tutorials. Some of them are

嗯,有很多 zlib 文章、技巧和教程。他们之中有一些是

1) Bobobobo's Blog

1) Bobobobo的博客

Website: http://bobobobo.wordpress.com/2008/02/23/how-to-use-zlib/

This article basically tells you how to use zlib, and there is a snippet of code that will get you going. This project shows you how to use zlib. Its a console project, because there's no need to create a window to demonstrate use of zlib.

网站:http: //bobobobo.wordpress.com/2008/02/23/how-to-use-zlib/

这篇文章主要告诉你如何使用 zlib,并且有一段代码可以让你开始。这个项目向你展示了如何使用 zlib。它是一个控制台项目,因为不需要创建一个窗口来演示 zlib 的使用。

2) zlib: Add Industrial Strength Compression to Your C/C++ Apps

2) zlib:为您的 C/C++ 应用程序添加工业强度压缩

Website: http://www.codeguru.com/cpp/cpp/algorithms/compression/article.php/c11735

For simplicity's sake, this tutorial covers only the basic C-style interface. All the concepts inherent there will be relevant to most other bindings. Since its in C language, it will be most beneficial to your requirements.

网站:http: //www.codeguru.com/cpp/cpp/algorithms/compression/article.php/c11735

为简单起见,本教程仅涵盖基本的 C 风格界面。那里固有的所有概念都与大多数其他绑定相关。由于它是C语言,因此最有利于您的要求。

Last, you can use this too available in zlib ... Zlib contains them. Have a look in the manual under "Utility Functions".

最后,您也可以在 zlib 中使用它... Zlib 包含它们。查看“实用程序功能”下的手册。

ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
                                   const Bytef *source, uLong sourceLen));

回答by Ben

http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/zlib.html

http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/zlib.html

Another option worth mentioning here is boost. Note you must compile boost with special flags for zlib support.

这里值得一提的另一个选择是提升。请注意,您必须使用特殊标志来编译 boost 以支持 zlib。

回答by Rudi Cilibrasi

The simplest way to use zlib is in C++ with

使用 zlib 的最简单方法是在 C++ 中使用

https://github.com/rudi-cilibrasi/zlibcomplete

https://github.com/rudi-cilibrasi/zlibcomplete

The zlibcomplete library makes it easy because you don't need to do any raw pointer manipulation whatsoever. It is based on RAII (Resource Allocation is Initialization) which means that all the dynamic allocation and deallocation stuff happens automatically in the constructors.

zlibcomplete 库使它变得简单,因为您不需要进行任何原始指针操作。它基于 RAII(资源分配即初始化),这意味着所有动态分配和释放的东西都会在构造函数中自动发生。

It is better than the Boost zlib wrapper because it supports flush (necessary for interactive network protocols) and is simpler to use. The zlibcomplete library uses only regular std::string to send and receive data so no advanced knowledge is required.

它比 Boost zlib 包装器更好,因为它支持刷新(交互式网络协议所必需的)并且更易于使用。zlibcomplete 库仅使用常规 std::string 来发送和接收数据,因此不需要任何高级知识。