C++封装zlib库压缩字符串
2016-01-06 本文已影响979人
明天不用上课
可以看一下我的Github项目,使用封装zlib库的ZLibString类进行压缩C++字符串。
- 使用
将ZLibString.h,ZLibString.cpp文件加入项目,使用以下方法进行压缩,解压缩。
// 压缩,pcContentBuf:要压缩的内容 pcCompBuf:压缩后的内容 ulCompLen:得到压缩后的长度
bool Compress(const char* pcContentBuf, char* pcCompBuf, unsigned long& ulCompLen);
// 解压,pcCompBuf:压缩的内容, pcUnCompBuf:解压后的内容 ulCompLen:传入压缩内容的长度
bool UnCompress(const char* pcCompBuf, char* pcUnCompBuf, unsigned long ulCompLen);
```
具体见源码。