24 constexpr
unsigned int bufsize = 4096;
27 const unsigned int threshsize = 32 * 1024 * 1024;
31 lzma_stream strm = LZMA_STREAM_INIT;
32 lzma_ret
ret = lzma_easy_encoder(&strm, preset, LZMA_CHECK_CRC64);
34 lzma_action
action = LZMA_RUN;
36 strm.next_in =
reinterpret_cast<uint8_t *
>(&inbuf[0]);
38 strm.next_out =
output.data();
39 strm.avail_out =
output.size();
41 unsigned int compressedSize = 0;
43 while (
ret == LZMA_OK) {
45 if (strm.avail_in == 0 && !
input.eof()) {
46 input.read(inbuf, bufsize);
47 strm.next_in =
reinterpret_cast<uint8_t *
>(&inbuf[0]);
48 strm.avail_in =
input.gcount();
59 compressedSize =
output.size() - strm.avail_out;
62 if (strm.avail_out == 0 &&
ret == LZMA_OK) {
63 unsigned int oldsize =
output.size();
64 if (oldsize < threshsize) {
65 output.resize(2 * oldsize);
67 output.resize(oldsize + threshsize);
69 strm.next_out = &
output[oldsize];
70 strm.avail_out =
output.size() - oldsize;
76 if (
ret != LZMA_STREAM_END) {
77 throw cms::Exception(
"CompressionError") <<
"There was a failure in LZMA compression in LHEXMLStringProduct.";
81 output.resize(compressedSize);
86 lzma_stream strm = LZMA_STREAM_INIT;
87 lzma_ret
ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
89 lzma_action
action = LZMA_FINISH;
92 constexpr
unsigned int bufsize = 4096;
97 strm.next_in =
input.data();
98 strm.avail_in =
input.size();
99 strm.next_out =
reinterpret_cast<uint8_t *
>(&outbuf[0]);
100 strm.avail_out = bufsize;
102 while (
ret == LZMA_OK) {
106 output.write(outbuf, bufsize - strm.avail_out);
109 if (strm.avail_out == 0 &&
ret == LZMA_OK) {
110 strm.next_out =
reinterpret_cast<uint8_t *
>(&outbuf[0]);
111 strm.avail_out = bufsize;
117 if (
ret != LZMA_STREAM_END) {
118 throw cms::Exception(
"DecompressionError") <<
"There was a failure in LZMA decompression in LHEXMLStringProduct.";
void swap(LHEXMLStringProduct &other)
ret
prodAgent to be discontinued
static std::string const input
void writeCompressedContent(std::ostream &output, unsigned int i) const
virtual ~LHEXMLStringProduct()
std::vector< std::vector< uint8_t > > compressedContent_
std::vector< std::string > content_
bool mergeProduct(LHEXMLStringProduct const &other)
void fillCompressedContent(std::istream &input, unsigned int initialSize=4 *1024 *1024)