CMS 3D CMS Logo

Namespaces | Functions
CStringStream.cc File Reference
#include <cassert>
#include <cstring>
#include "zlib.h"
#include "Alignment/Geners/interface/BZ2Handle.hh"
#include "Alignment/Geners/interface/CStringStream.hh"
#include "Alignment/Geners/interface/IOException.hh"

Go to the source code of this file.

Namespaces

 gs
 

Functions

static void doBZ2Compression (const char *data, const unsigned long long len, const bool defl, bz_stream &strm, char *buffer, const unsigned long long bufLen, std::ostream &sink)
 
static void doZlibCompression (const char *data, const unsigned long long len, const bool defl, z_stream_s &strm, char *buffer, const unsigned long long bufLen, std::ostream &sink)
 

Function Documentation

◆ doBZ2Compression()

static void doBZ2Compression ( const char *  data,
const unsigned long long  len,
const bool  defl,
bz_stream &  strm,
char *  buffer,
const unsigned long long  bufLen,
std::ostream &  sink 
)
static

Definition at line 42 of file CStringStream.cc.

References cms::cuda::assert(), edmScanValgrind::buffer, data, and mps_update::status.

48  {
49  assert(buffer);
50  assert(bufLen);
51 
52  int status = BZ_OK;
53  strm.next_in = const_cast<char *>(data);
54  strm.avail_in = len;
55  do {
56  strm.next_out = buffer;
57  strm.avail_out = bufLen;
58  status = defl ? BZ2_bzCompress(&strm, BZ_FINISH) : BZ2_bzDecompress(&strm);
59  assert(status == BZ_OK || status == BZ_STREAM_END);
60  const unsigned have = bufLen - strm.avail_out;
61  sink.write(buffer, have);
62  if (sink.fail())
63  throw gs::IOWriteFailure("In gs::doBZ2Compression: sink stream failure");
64  } while (status != BZ_STREAM_END);
65 }
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ doZlibCompression()

static void doZlibCompression ( const char *  data,
const unsigned long long  len,
const bool  defl,
z_stream_s &  strm,
char *  buffer,
const unsigned long long  bufLen,
std::ostream &  sink 
)
static

Definition at line 10 of file CStringStream.cc.

References cms::cuda::assert(), edmScanValgrind::buffer, data, and mps_update::status.

16  {
17  assert(buffer);
18  assert(bufLen);
19 
20  int status = Z_OK;
21  strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(data));
22  strm.avail_in = len;
23  do {
24  strm.next_out = reinterpret_cast<Bytef *>(buffer);
25  strm.avail_out = bufLen;
26  status = defl ? deflate(&strm, Z_FINISH) : inflate(&strm, Z_NO_FLUSH);
27  assert(status == Z_OK || status == Z_STREAM_END);
28  const unsigned have = bufLen - strm.avail_out;
29  sink.write(buffer, have);
30  if (sink.fail())
31  throw gs::IOWriteFailure("In gs::doZlibCompression: sink stream failure");
32  } while (strm.avail_out == 0);
33 
34  if (defl) {
35  assert(strm.avail_in == 0);
36  assert(status == Z_STREAM_END);
37  assert(deflateReset(&strm) == Z_OK);
38  } else
39  assert(inflateReset(&strm) == Z_OK);
40 }
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80