DATRW++ library: seismic data I/O with multiple formats

◆ read()

void datrw::thiesdl1::File::read ( std::istream &  is,
const FileHeader header 
)

actually read file

Definition at line 241 of file thiesdl1file.cc.

References DATRW_assert, DATRW_nonfatal_assert, datrw::thiesdl1::FileHeader::earliestdate, datrw::thiesdl1::FileHeader::expectedfinaldataline, header(), datrw::thiesdl1::FileHeader::latestdate, Mbetolerantagainstwrongtime, Mfilled, Mheader, Miseries, Mnsamples, Mreadsuccessfully, Mreadyforreading, datrw::thiesdl1::FileHeader::nsamples(), and put().

Referenced by datrw::ithiesdl1stream::readsamples(), and readwithheader().

242  {
243  Mheader=header;
245  "ERROR: File container is not empty");
246  Mreadsuccessfully=false;
247  Mreadyforreading=false;
248  libtime::TRelativeTime fileduration=Mheader.latestdate-
251  fileduration<libtime::TRelativeTime(5),
252  "Duration of file is larger than 5 days!\n"
253  "earlist sample: "
254  << Mheader.earliestdate.timestring()
255  << "\n"
256  << "latest sample: "
257  << Mheader.latestdate.timestring()
258  << "\n");
259  // prepare sample container
262  Miseries=0;
263  Mfilled=aff::Series<bool>(Mnsamples);
264  Mfilled=false;
265  // read samples
266  bool hot=true;
267  while (hot && is.good())
268  {
269  std::string line;
270  DATRW_assert(getline(is, line), "ERROR: reading file");
271  if (line==Mheader.expectedfinaldataline)
272  {
273  hot=false;
274  }
275  else
276  {
277  DataLine dataline(line);
278  this->put(line);
279  }
280  } // while (hot && is.good())
281  DATRW_assert(!hot, "missed expected last line of data file");
282  Mreadsuccessfully=true;
283  } // void File::read(std::istream& is)
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
bool Mbetolerantagainstwrongtime
mode: do not abort upon wrong sample time
Definition: thiesdl1file.h:196
unsigned int Mnsamples
number of samples
Definition: thiesdl1file.h:183
unsigned int nsamples() const
number of samples
FileHeader header() const
return file header
Definition: thiesdl1file.h:160
aff::Series< bool > Mfilled
an array to keep track of samples
Definition: thiesdl1file.h:189
Tiseries Miseries
prepare are series of counts
Definition: thiesdl1file.h:187
libtime::TAbsoluteTime latestdate
latest date
Definition: thiesdl1file.h:102
bool Mreadyforreading
is this container empty and ready for reading?
Definition: thiesdl1file.h:177
FileHeader Mheader
file header
Definition: thiesdl1file.h:181
aff::Series< int > Tiseries
Definition: types.h:47
#define DATRW_nonfatal_assert(F, C, M)
Macro to distinguish between fatal and non fatal assertions.
Definition: error.h:138
std::string expectedfinaldataline
Expected final data line (as announced in header lines)
Definition: thiesdl1file.h:96
libtime::TAbsoluteTime earliestdate
earliest date
Definition: thiesdl1file.h:100
bool Mreadsuccessfully
true if data was read successfully
Definition: thiesdl1file.h:179
void put(const DataLine &line)
drop a data line
Here is the call graph for this function:
Here is the caller graph for this function: