Search code examples
c++zlibstringstreamstdstringdeflate

Using zlib for std::string and stringstream


I am using zlib for deflating string on the client side and inflating on the server side.

I found a link which does exactly this using char buffers: https://gist.github.com/arq5x/5315739

Can someone post simple examples using zlib methods for std::string and std::stringstream for doing the same?

EDIT: Please don't use Boost, as I am developing a restricted API.


Solution

  • So, I found out from zlib.h documentation and examples.c which come with downloaded zlib, that you can only use files or char buffers for compression. So, convert string or stringstreams to char buffers.

    Here is the code: https://panthema.net/2007/0328-ZLibString.html