CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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 45 of file CStringStream.cc.

References assert(), AlCaHLTBitMon_QueryRunRegistry::data, and ntuplemaker::status.

49 {
50  assert(buffer);
51  assert(bufLen);
52 
53  int status = BZ_OK;
54  strm.next_in = const_cast<char*>(data);
55  strm.avail_in = len;
56  do
57  {
58  strm.next_out = buffer;
59  strm.avail_out = bufLen;
60  status = defl ? BZ2_bzCompress(&strm, BZ_FINISH) :
61  BZ2_bzDecompress(&strm);
62  assert(status == BZ_OK || status == BZ_STREAM_END);
63  const unsigned have = bufLen - strm.avail_out;
64  sink.write(buffer, have);
65  if (sink.fail()) throw gs::IOWriteFailure(
66  "In gs::doBZ2Compression: sink stream failure");
67  } while (status != BZ_STREAM_END);
68 }
assert(m_qm.get())
tuple status
Definition: ntuplemaker.py:245
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 assert(), AlCaHLTBitMon_QueryRunRegistry::data, and ntuplemaker::status.

14 {
15  assert(buffer);
16  assert(bufLen);
17 
18  int status = Z_OK;
19  strm.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(data));
20  strm.avail_in = len;
21  do
22  {
23  strm.next_out = reinterpret_cast<Bytef*>(buffer);
24  strm.avail_out = bufLen;
25  status = defl ? deflate(&strm, Z_FINISH) :
26  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()) throw gs::IOWriteFailure(
31  "In gs::doZlibCompression: sink stream failure");
32  } while (strm.avail_out == 0);
33 
34  if (defl)
35  {
36  assert(strm.avail_in == 0);
37  assert(status == Z_STREAM_END);
38  assert(deflateReset(&strm) == Z_OK);
39  }
40  else
41  assert(inflateReset(&strm) == Z_OK);
42 }
assert(m_qm.get())
tuple status
Definition: ntuplemaker.py:245