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

◆ readheader()

Header datrw::pdas::readheader ( std::istream &  is,
const bool &  verbose 
)

function to read the file header

Definition at line 82 of file pdasread.cc.

References datrw::pdas::Header::comment, datrw::pdas::Header::dataset, datrw::pdas::Header::date, DATRW_abort, FtypeGAINRANGED, FtypeINT, FtypeLONG, datrw::pdas::Header::horzunits, datrw::pdas::Header::interval, datrw::pdas::HeaderLine::line, datrw::pdas::Header::lines, readline(), datrw::pdas::Header::signal, datrw::pdas::Header::time, datrw::pdas::HeaderLine::token, datrw::pdas::Header::type, datrw::pdas::HeaderLine::value, datrw::pdas::Header::version, and datrw::pdas::Header::vertunits.

Referenced by main(), and datrw::ipdasstream::readheader().

83  {
84  Header retval;
85  HeaderLine hdline;
86  while (hdline.line!="DATA")
87  {
88  hdline=readline(is, verbose);
89  retval.lines.push_back(hdline.line);
90  if (hdline.token=="DATASET")
91  { retval.dataset=hdline.value; }
92  else if (hdline.token=="SIGNAL")
93  { retval.signal=hdline.value; }
94  else if (hdline.token=="VERSION")
95  { retval.version=hdline.value; }
96  else if (hdline.token=="DATE")
97  { retval.date=hdline.value; }
98  else if (hdline.token=="TIME")
99  { retval.time=hdline.value; }
100  else if (hdline.token=="INTERVAL")
101  { retval.interval=hdline.value; }
102  else if (hdline.token=="VERT_UNITS")
103  { retval.vertunits=hdline.value; }
104  else if (hdline.token=="HORZ_UNITS")
105  { retval.horzunits=hdline.value; }
106  else if (hdline.token=="COMMENT")
107  {
108  retval.comment=hdline.value;
109  if (retval.type == FtypeLONG)
110  {
111  if (hdline.value=="GAINRANGED")
112  { retval.type=FtypeGAINRANGED; }
113  }
114  }
115  else if (hdline.token=="FILE_TYPE")
116  {
117  if (hdline.value=="INT")
118  { retval.type=FtypeINT; }
119  else if (hdline.value=="LONG")
120  { retval.type=FtypeLONG; }
121  else
122  { DATRW_abort("ERROR: unsupported data type!"); }
123  }
124  }
125  if (verbose)
126  {
127  std::cout << "dataset: " << retval.dataset << std::endl;
128  std::cout << "signal: " << retval.signal << std::endl;
129  std::cout << "version: " << retval.version << std::endl;
130  std::cout << "date: " << retval.date << std::endl;
131  std::cout << "time: " << retval.time << std::endl;
132  std::cout << "interval: " << retval.interval << std::endl;
133  std::cout << "vert units: " << retval.vertunits << std::endl;
134  std::cout << "horz units: " << retval.horzunits << std::endl;
135  std::cout << "comment: " << retval.comment << std::endl;
136  std::cout << "data type: ";
137  if (retval.type==FtypeINT)
138  { std::cout << "INT integer" << std::endl; }
139  else
140  { std::cout << "unknown!" << std::endl; }
141  }
142  return(retval);
143  }
HeaderLine readline(std::istream &is, const bool &verbose)
function to read the file header line
Definition: pdasread.cc:55
#define DATRW_abort(M)
Abort and give a message.
Definition: error.h:101
Here is the call graph for this function:
Here is the caller graph for this function: