Environment: OS independent
Now, many applications need API to do Gzip in memory. The Zlib form, http://www.gzip.org/zlib, provides Gzip and unGzip function, but they are for files. It's very inconvenient to compress and decompress small data that could be compressed in memory. I ported the Gzip and unGzip functions to two template classes, CA2GZIP and CGZIP2A, to do Gzip in memory; they also allocate and deallocate memory automatically. It works with zlib from http://www.gzip.org/zlib. The following is some code for how to use them.
#include "GZipHelper.h"
void main()
{
char plainText[]="Plain text here";
CA2GZIP gzip(plainText,strlen(plainText));
LPGZIP pgzip=gzip.pgzip;
int len=gzip.Length;
CGZIP2A plain(pgzip,len);
char *pplain=plain.psz;
int aLen=plain.Length;
}
Downloads
Download demo project - 131 Kb