zlib を少し調べたので、std::string に対して、 deflate と inflate を行うクラスを作ってみた。
//ZlibUtil.h //ZlibUtilTest.cc
#include "ZlibUtil.h"
int main(int argc, char **argv)
{
int ret;
ZlibUtil zlib;
std::string from, to;
from = "あいうえおあいうえおあいうえおあいうえおあいうえお";
ret = zlib.def(from, to, 9);
printf("compress=%s %d\n", to.c_str(), to.length());
ret = zlib.inf(to, from);
printf("decompress=%s %d\n", from.c_str(), from.length());
}
[sikaku@localhost compress]$ ./zlibutil
compress=xレ{ワリア蚋cロ翦?])・27
decompress=あいうえおあいうえおあいうえおあいうえおあいうえお 75
No comments:
Post a Comment