Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 510
V Shreyas Avatar asked Jun 08 '26 20:06

V Shreyas


1 Answers

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

like image 184
V Shreyas Avatar answered Jun 11 '26 16:06

V Shreyas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!