SFF++ library: reading and writing SFF from C++

◆ read()

void sff::STAT::read ( std::istream &  is,
const bool &  debug = false 
)

Definition at line 236 of file sffxx.cc.

References decode_libversion, hasfree, hassrce, libversion, and timestamp.

Referenced by sff::FileHeader::read(), and STAT().

237  {
238  if (debug) { std::cerr << "DEBUG (STAT::read):" << std::endl; }
239  // read complete line
240  std::string theline;
241  std::getline(fis, theline);
242 
243  if (debug) { std::cerr << theline << std::endl; }
244  std::string lineID=theline.substr(0,4);
245  if (debug) { std::cerr << lineID << std::endl; }
246  if (!helper::IDmatch<STAT>(lineID)) throw
247  GSE2::Terror("ERROR (STAT::read): missing STAT ID!");
248 
249  double inlibversion=atof(theline.substr(5,7).c_str());
250  if (inlibversion>STAT::libversion)
251  {
252  std::cerr << "ERROR (STAT::read): "
253  << "data file has format version "
254  << inlibversion << std::endl;
255  std::cerr << "ERROR (STAT::read): "
256  << "library can decode formats up to version "
257  << STAT::libversion << std::endl;
258  throw
259  GSE2::Terror("ERROR (STAT::read): file library version too large!");
260  }
261  if (inlibversion<STAT::decode_libversion)
262  {
263 // std::cerr << "theline " << theline << std::endl;
264 // std::cerr << "theline.lv " << theline.substr(5,6) << std::endl;
265 // std::cerr << "inlibversion " << inlibversion << std::endl;
266 // std::cerr << "decode_libversion " << decode_libversion << std::endl;
267  std::cerr << "ERROR (STAT::read): "
268  << "data file has format version "
269  << inlibversion << std::endl;
270  std::cerr << "ERROR (STAT::read): "
271  << "library can decode formats from version "
273  << " up to version "
274  << STAT::libversion << std::endl;
275  throw
276  GSE2::Terror("ERROR (STAT::read): incompatible SFF version!");
277  }
278 
279  this->timestamp=theline.substr(13,13);
280 
281  std::string code=theline.substr(27,10);
282 // std::cerr << "code " << code << std::endl;
283  this->hasfree=(code.find('F')!=std::string::npos);
284  this->hassrce=(code.find('S')!=std::string::npos);
285  if (debug)
286  {
287  if (this->hasfree)
288  { std::cerr << "DEBUG (STAT::read): has FREE block" << std::endl; }
289  if (this->hassrce)
290  { std::cerr << "DEBUG (STAT::read): has SRCE line" << std::endl; }
291  std::cerr << "DEBUG (STAT::read): finished" << std::endl;
292  }
293  } // void STAT::read(std::istream& fis, const bool& debug)
std::string timestamp
Definition: sffxx.h:148
static const double decode_libversion
Definition: sffxx.h:140
static const double libversion
Fortran library version (to ensure compatibility)
Definition: sffxx.h:139
bool hasfree
Definition: sffxx.h:149
bool hassrce
Definition: sffxx.h:150
Here is the caller graph for this function: