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

◆ readany()

template<typename T >
std::string datrw::ascii::anonymous_namespace{iasciistream.cc}::readany ( std::istream &  is,
const unsigned int &  n,
const std::string &  firstline,
typename aff::Series< T > &  series,
const std::string &  datatype,
const bool &  nonfatal 
)

read a sequence of samples

Read a sequence of samples being regarded as a contiguous trace. This function essential performs the correct type conversion after reading the data with function readsamples().

Parameters
Ttype of sample value (double, float, int)
isinput stream to read from
nexpected number of samples
firstlinefirst line from input, which is already read
seriescontainer to write samples to
datatypeexpected type of data
nonfatalerrors are made nonfatal if true
Returns
next input line

Definition at line 412 of file iasciistream.cc.

References datrw::util::convert(), DATRW_abort, datrw::ascii::keydouble, datrw::ascii::keyfloat, datrw::ascii::keyint, datrw::mseed::key::nonfatal, and readsamples().

Referenced by datrw::iasciistream::dseries(), datrw::iasciistream::fseries(), and datrw::iasciistream::iseries().

418  {
419  //typedef typename aff::Series<T> Tinseries;
420  std::string line;
421  if (datatype==ascii::keydouble)
422  {
423  Tdseries inseries;
424  line=readsamples(is, n, firstline, inseries, nonfatal);
425  util::convert(inseries, series);
426  }
427  else if (datatype==ascii::keyfloat)
428  {
429  Tfseries inseries;
430  line=readsamples(is, n, firstline, inseries, nonfatal);
431  util::convert(inseries, series);
432  }
433  else if (datatype==ascii::keyint)
434  {
435  Tiseries inseries;
436  line=readsamples(is, n, firstline, inseries, nonfatal);
437  util::convert(inseries, series);
438  }
439  else
440  {
441  std::cerr << "unrecognized data type: " << datatype << std::endl;
442  DATRW_abort("unkown data type!");
443  }
444  return(line);
445  }
const char *const keydouble
key for DATA type header field
Definition: ascii.cc:73
aff::Series< float > Tfseries
Definition: types.h:46
aff::Series< Tivalue > Tiseries
Definition: gseread.h:63
aff::Series< double > Tdseries
Definition: types.h:45
const char *const keyint
key for DATA type header field
Definition: ascii.cc:71
libtime::TAbsoluteTime convert(const SEED::BTIME &t)
convert BTIME structure to libtime structure
Definition: mseedread.cc:166
#define DATRW_abort(M)
Abort and give a message.
Definition: error.h:101
const char *const keyfloat
key for DATA type header field
Definition: ascii.cc:72
std::string readsamples(std::istream &is, const unsigned int &n, const std::string &firstline, typename aff::Series< T > &series, const bool &nonfatal)
const char *const nonfatal
keywords for format modifiers
Here is the call graph for this function:
Here is the caller graph for this function: