55 if ( ! input ) { mode = ios_base::out|ios_base::binary; }
62 <<
"; all I/O will fail." << endl;
86 #define READ_BUILTIN(t) \
88 FairDbBinaryFile& FairDbBinaryFile::operator >> (t& v) { \
89 UInt_t numBytes = sizeof(v); \
90 char* bytes = reinterpret_cast<char*>(&v); \
91 this->Read(bytes,numBytes); \
94 #define WRITE_BUILTIN(t) \
96 FairDbBinaryFile& FairDbBinaryFile::operator << (const t& v) { \
97 UInt_t numBytes = sizeof(v); \
98 const char* bytes = reinterpret_cast<const char*>(&v); \
99 this->Write(bytes,numBytes); \
114 #define READ_SIMPLE(t) \
116 FairDbBinaryFile& FairDbBinaryFile::operator >> (t& v) { \
117 void* vt = GetVTptr(&v); \
118 UInt_t numBytes = sizeof(v); \
119 char* bytes = reinterpret_cast<char*>(&v); \
120 this->Read(bytes,numBytes); \
124 #define WRITE_SIMPLE(t) \
126 FairDbBinaryFile& FairDbBinaryFile::operator << (const t& v) { \
127 UInt_t numBytes = sizeof(v); \
128 const char* bytes = reinterpret_cast<const char*>(&v); \
129 this->Write(bytes,numBytes); \
140 if ( this->CanRead() ) {
142 this->CheckFileStatus();
150 UInt_t numBytes = str.size()+1;
151 this->
Write(str.c_str(),numBytes);
164 (*this) >> detectorMask
169 TString dataSource(str.c_str());
170 ValRange tmp(detectorMask,simMask,timeStart,timeEnd,dataSource);
192 if ( ! this->
CanRead() ) {
return *
this; }
195 cout <<
"Attempting to read into non-empty array" << endl;
204 cout <<
"Cannot find start of array marker" << endl;
218 (*this) >> objName >> objSize;
224 TClass objClass(objName.c_str());
225 Int_t objSizefromRoot = objClass.Size();
226 void* obj = objClass.New();
234 <<
"Restoring array of " << arrSize <<
" "
235 << objName <<
" objects"
236 <<
" VTaddr " << hex << vt << dec
237 <<
" object size " << objSize <<
"(from file) "
238 << objSizefromRoot <<
"(from ROOT)"
241 if ( arrSize < 0 || objSize != objSizefromRoot ) {
242 cout <<
"Illegal array size ("<< arrSize
243 <<
") or object size(" << objSize
244 <<
"," << objSizefromRoot <<
")" << endl;
252 Int_t buffSize = arrSize*objSize;
259 arr.reserve(arrSize);
260 for (
int row = 0; row < arrSize; ++row ) {
262 arr.push_back(reinterpret_cast<FairDbTableRow*>(elem));
272 cout <<
"Cannot find end of array marker" << endl;
285 if ( ! this->CanWrite() ) {
return *
this; }
289 Int_t arrSize = arr.size();
294 Int_t objSize = obj->IsA()->Size();
295 string objName = obj->ClassName();
296 (*this) << objName << objSize;
297 for (
int row = 0; row < arrSize; ++row ) {
299 const char*
p =
reinterpret_cast<const char*
>(arr[row]);
300 this->Write(p,objSize);
317 cout <<
"Attempting to read from a write-only file" << endl;
328 cout <<
"Attempting to write to a read-only file" << endl;
343 && ( !
fFile->is_open() || !
fFile->good() ) ) {
344 cout <<
"File not open or has gone bad,"
345 <<
" all further I/O will fail." << endl;
362 if ( ! this->
CanRead() ) {
return kFALSE; }
364 fFile->read(bytes,numBytes);
372 if ( ! this->
CanWrite() ) {
return kFALSE; }
374 fFile->write(bytes,numBytes);