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

◆ readline()

HeaderLine datrw::pdas::readline ( std::istream &  is,
const bool &  verbose 
)

function to read the file header line

Definition at line 55 of file pdasread.cc.

References DATRW_assert, datrw::pdas::HeaderLine::line, datrw::pdas::HeaderLine::token, and datrw::pdas::HeaderLine::value.

Referenced by readheader().

56  {
57  HeaderLine retval;
58  DATRW_assert(is.good(), "ERROR: unexpected end of file!");
59  std::getline(is, retval.line);
60  // remove CR
61  unsigned long long int delim=retval.line.find_first_of(0x0D);
62  retval.line.erase(delim);
63  // strip value from token
64  delim=retval.line.find_first_of(' ');
65  if (delim!=std::string::npos)
66  {
67  retval.token=retval.line.substr(0,delim);
68  retval.value=retval.line.substr(delim+1);
69  }
70  if (verbose)
71  {
72  std::cout << "line: " << retval.line << std::endl;
73  std::cout << " token: \"" << retval.token << "\"" << std::endl;
74  std::cout << " value: \"" << retval.value << "\"" << std::endl;
75  }
76  return(retval);
77  }
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
Here is the caller graph for this function: