Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
compression.cpp
Go to the documentation of this file.
2
3#include <boost/iostreams/device/back_inserter.hpp>
4#include <boost/iostreams/filter/zlib.hpp>
5#include <boost/iostreams/filtering_stream.hpp>
6
7namespace sysio {
8namespace state_history {
9
10namespace bio = boost::iostreams;
12 bytes out;
13 bio::filtering_ostream comp;
14 comp.push(bio::zlib_compressor(bio::zlib::default_compression));
15 comp.push(bio::back_inserter(out));
16 bio::write(comp, in.data(), in.size());
17 bio::close(comp);
18 return out;
19}
20
22 bytes out;
23 bio::filtering_ostream decomp;
24 decomp.push(bio::zlib_decompressor());
25 decomp.push(bio::back_inserter(out));
26 bio::write(decomp, in.data(), in.size());
27 bio::close(decomp);
28 return out;
29}
30
31} // namespace state_history
32} // namespace sysio
bytes zlib_compress_bytes(const bytes &in)
bytes zlib_decompress(const bytes &in)