CMS 3D CMS Logo

StreamerFileIO.cc
Go to the documentation of this file.
2 #include <fstream>
3 #include <iostream>
6 
8  : current_offset_(1),
9  do_adler_(false),
10  adlera_(1),
11  adlerb_(0),
12  ost_(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out)),
13  filename_(name) {
14  if (!ost_->is_open()) {
15  throw cms::Exception("OutputFile", "OutputFile") << "Error Opening Output File: " << name << "\n";
16  }
17  ost_->rdbuf()->pubsetbuf(nullptr, 0);
18 }
19 
21 
22 bool OutputFile::write(const char* ptr, size_t n) {
23  ost_->write(ptr, n);
24  if (!ost_->fail()) {
25  current_offset_ += (uint64)(n);
26  if (do_adler_)
27  cms::Adler32(ptr, n, adlera_, adlerb_);
28  return false;
29  }
30  return true;
31 }
32 
33 void OutputFile::close() { ost_->close(); }
uint64 current_offset_
OutputFile(const std::string &name)
bool write(const char *ptr, size_t n)
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
unsigned long long uint64
Definition: MsgTools.h:14
edm::propagate_const< std::shared_ptr< std::ofstream > > ost_
uint32 adlerb_
uint32 adlera_