Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
static inline void
ctx.log()
.info("original size ${original}")
memory::buffer buf1{};
if(auto packed{comp.compress(original, buf1, level)}) {
ctx.log()
.info("packed size ${packed}")
memory::buffer buf2{};
if(auto unpacked{comp.decompress(packed, buf2)}) {
ctx.log()
.info("unpacked size ${unpacked}")
if(are_equal(original, unpacked)) {
const auto compr_ratio =
float(packed.size()) / float(unpacked.size());
ctx.log()
.info("original and unpacked block are equal")
} else {
ctx.log().error("original and unpacked block are different");
}
} else {
ctx.log().error("failed to unpack memory block");
}
} else {
ctx.log().error("failed to pack memory block");
}
}
auto main(main_ctx& ctx) -> int {
data_compressor comp{};
if(file_contents self{ctx.exe_path()}) {
pack_unpack(ctx, comp, self);
}
return 0;
}
}
@ highest
Slowest compression method highest compression level.