CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamerFileIO.cc
Go to the documentation of this file.
2 #include <fstream>
3 #include <iostream>
6 
7  OutputFile::OutputFile(const std::string& name):
8  current_offset_(1),
9  first_event_offset_(0),
10  last_event_offset_(0),
11  events_(0),
12  run_(0),
13  do_adler_(0),
14  adlera_(1),
15  adlerb_(0),
16  ost_(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out)),
17  filename_(name)
18  {
19  if(!ost_->is_open()) {
20  throw cms::Exception("OutputFile","OutputFile")
21  << "Error Opening Output File: "<<name<<"\n";
22  }
23  ost_->rdbuf()->pubsetbuf(0,0);
24  }
25 
27  {
28  ost_->close();
29  }
30 
31  bool OutputFile::write(const char *ptr, size_t n)
32  {
33  ost_->write(ptr,n);
34  if(!ost_->fail()) {
35  current_offset_ += (uint64)(n);
36  if (do_adler_)
38  return 0;
39  }
40  return 1;
41  }
42 
uint64 current_offset_
boost::shared_ptr< std::ofstream > ost_
OutputFile(const std::string &name)
bool write(const char *ptr, size_t n)
tuple out
Definition: dbtoconf.py:99
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
unsigned long long uint64
Definition: MsgTools.h:14
uint32 adlerb_
uint32 adlera_