开发者

Simple compression in c++

开发者 https://www.devze.com 2023-01-29 01:14 出处:网络
we have a C++ MFC application and C# Web Service. They are communicating over HTTP, but as they are exchanging text data, compression will help a lot. But for some reasons, wecan\'t use an external li

we have a C++ MFC application and C# Web Service. They are communicating over HTTP, but as they are exchanging text data, compression will help a lot. But for some reasons, we can't use an external library.

We basically开发者_运维百科 need to compress a byte array on one side and decompress it on the other side.

What should we use to compress our data? The best scenario would be if there is something in MFC/win32 api. Or is there some simplistic code with at most LGPL license that we could integrate into our project?


As has already been said, the zlib is probably what you are looking for.

There are several algorithms within:

  • The deflate and inflate pair
  • zlib itself
  • lzo

The simpler is probably lzo (I advise to pass the uncompressed size on the side), but zlib isn't very complicated either and the compression rate can be parameterized (speed / size trade off) which can be a plus depending on your constraints.

For XML data (since you were speaking of web services), LZO gave me a ~4x compression factor.


Can't you just switch on HTTP compression? http://en.wikipedia.org/wiki/HTTP_compression


zlib has a very liberal license.

0

精彩评论

暂无评论...
验证码 换一张
取 消