DATRW++ library: seismic data I/O with multiple formats
iasciistream.cc
Go to the documentation of this file.
1 /*! \file iasciistream.cc
2  * \brief input raw ASCII data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 18/10/2011
8  *
9  * input raw ASCII data (implementation)
10  *
11  * Copyright (c) 2011 by Thomas Forbriger (BFO Schiltach)
12  *
13  * ----
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27  * ----
28  *
29  *
30  * REVISIONS and CHANGES
31  * - 18/10/2011 V1.0 Thomas Forbriger (thof)
32  * - 12/06/2012 V1.1 settraceheader must not be called before actual
33  * number of samples ist set
34  * correction in skipseries()
35  * - 08/07/2016 V1.2 thof:
36  * - make correct use of new DATRW_report_assert
37  * - make correct use of new DATRW_nonfatal_assert
38  * - 18/11/2016 V1.3 use debug flag in base class
39  *
40  * ============================================================================
41  */
42 #define DATRW_IASCIISTREAM_CC_VERSION \
43  "DATRW_IASCIISTREAM_CC V1.3"
44 
45 #include<iomanip>
46 #include<vector>
47 #include<aff/subarray.h>
48 #include<datrwxx/ascii.h>
50 #include<datrwxx/asciiheaderkeys.h>
51 #include<datrwxx/util.h>
52 #include<datrwxx/datatypes.h>
53 
54 namespace datrw {
55 
56  const std::ios_base::openmode
57  iasciistream::openmode=std::ios_base::in;
58 
59  /*----------------------------------------------------------------------*/
60 
61  iasciistream::iasciistream(std::istream& is,
62  const std::string& modifier,
63  const bool& debug):
64  Tbase(is, true, true, true, debug), Mmodifier(modifier)
65  {
66  // format modifiers must be used here to set defaults
67  datrw::Subformat subformat(Mmodifier);
68  // WID2
69  {
70  libtime::TAbsoluteTime date(subformat.value(ascii::keydate,"2000/1/1"));
71  this->Mdefaultwid2.date=date;
72  }
73  subformat(ascii::keydt, "1.") >> this->Mdefaultwid2.dt;
74  subformat(ascii::keynsamples, "0") >> this->Mdefaultwid2.nsamples;
75  subformat(ascii::keyhang, "-1.") >> this->Mdefaultwid2.hang;
76  subformat(ascii::keyvang, "90.") >> this->Mdefaultwid2.vang;
77  subformat(ascii::keycalib, "1.") >> this->Mdefaultwid2.calib;
78  subformat(ascii::keycalper, "1.") >> this->Mdefaultwid2.calper;
79  this->Mdefaultwid2.station=subformat.value(ascii::keystation,"NSP");
80  this->Mdefaultwid2.channel=subformat.value(ascii::keychannel,"NSP");
81  this->Mdefaultwid2.auxid=subformat.value(ascii::keyauxid,"NSP");
82  this->Mdefaultwid2.instype=subformat.value(ascii::keyinstype,"NSP");
83  // INFO
84  subformat(ascii::keynstacks, "1") >> this->Mdefaultinfo.nstacks;
85  subformat(ascii::keyRECVX, "0.") >> this->Mdefaultinfo.cx;
86  subformat(ascii::keyRECVY, "0.") >> this->Mdefaultinfo.cy;
87  subformat(ascii::keyRECVZ, "0.") >> this->Mdefaultinfo.cz;
88  this->Mdefaultinfo.cs
89  =::sff::coosysID(subformat.value(ascii::keyRECVCS,"C").c_str()[0]);
90  // SRCE
91  subformat(ascii::keySRCEX, "0.") >> this->Mdefaultsrce.cx;
92  subformat(ascii::keySRCEY, "0.") >> this->Mdefaultsrce.cy;
93  subformat(ascii::keySRCEZ, "0.") >> this->Mdefaultsrce.cz;
94  {
95  libtime::TAbsoluteTime
96  date(subformat.value(ascii::keySRCEdate,"2000/1/1"));
97  this->Mdefaultsrce.date=date;
98  }
99  this->Mdefaultsrce.type=subformat.value(ascii::keySRCEtype,"NSP");
100  this->Mdefaultsrce.cs
101  =::sff::coosysID(subformat.value(ascii::keySRCECS,"C").c_str()[0]);
102 
103  this->Mnonfatal=subformat.isset(ascii::keynonfatal);
104 
106  "iasciistream");
107 
108  // read first line
109  std::getline(Mis, this->Mcurrentline);
110  this->readheader();
111  // take FREE blocks only for traces, otherwise FREE blocks will be
112  // mutliplied when reading and rewriting ASCII data
113  // if (this->Mreadfree) { this->setfilefree(this->Mcurrentfree); }
114  if (this->Mreadsrce) { this->setsrce(this->Mcurrentsrce); }
115  } // iasciistream::iasciistream
116 
117  /*----------------------------------------------------------------------*/
118 
119  /*! this function reads all header lines until the next trace data is found
120  */
122  {
123  // set defaults of header fields
124  this->Mcurrentwid2=this->Mdefaultwid2;
125  this->Mcurrentinfo=this->Mdefaultinfo;
126  this->Mcurrentsrce=this->Mdefaultsrce;
127 
128  this->Mcurrentfree.lines.clear();
129 
131 
132  this->Mnsamples=0;
133 
134  this->Mreadinfo=false;
135  this->Mreadfree=false;
136  this->Mreadsrce=false;
137  // scan input lines until data is found
138  while ((this->Mcurrentline.substr(0,1)=="#") && Mis.good())
139  {
140  if (this->Mcurrentline.substr(0,2)=="##")
141  {
142  this->Mreadfree=true;
143  this->Mcurrentfree.append(util::trimws(this->Mcurrentline.substr(2)));
144  }
145  else
146  {
147  std::string value=this->Mcurrentline.substr(1);
148  std::string key=util::clipstring(value, ":");
149  value=util::trimws(value);
150  key=util::trimws(key);
151  if (key==ascii::keydate)
152  {
153  this->Mcurrentwid2.date=libtime::TAbsoluteTime(value);
154  }
155  else if (key==ascii::keystation)
156  {
157  this->Mcurrentwid2.station=value;
158  }
159  else if (key==ascii::keychannel)
160  {
161  this->Mcurrentwid2.channel=value;
162  }
163  else if (key==ascii::keyauxid)
164  {
165  this->Mcurrentwid2.auxid=value;
166  }
167  else if (key==ascii::keyinstype)
168  {
169  this->Mcurrentwid2.instype=value;
170  }
171  else if (key==ascii::keyRECVCS)
172  {
173  this->Mreadinfo=true;
174  this->Mcurrentinfo.cs=::sff::coosysID(value.c_str()[0]);
175  }
176  else if (key==ascii::keySRCEdate)
177  {
178  this->Mreadsrce=true;
179  this->Mcurrentsrce.date=libtime::TAbsoluteTime(value);
180  }
181  else if (key==ascii::keySRCEtype)
182  {
183  this->Mreadsrce=true;
184  this->Mcurrentsrce.type=value;
185  }
186  else if (key==ascii::keySRCECS)
187  {
188  this->Mreadsrce=true;
189  this->Mcurrentsrce.cs=::sff::coosysID(value.c_str()[0]);
190  }
191  else if (key==ascii::keydata)
192  {
193  this->Mdatatype=value;
194  }
195  else
196  {
197  std::istringstream iss(value);
198  if (key==ascii::keynsamples)
199  {
200  iss >> this->Mcurrentwid2.nsamples;
201  }
202  else if (key==ascii::keydt)
203  {
204  iss >> this->Mcurrentwid2.dt;
205  }
206  else if (key==ascii::keyhang)
207  {
208  iss >> this->Mcurrentwid2.hang;
209  }
210  else if (key==ascii::keyvang)
211  {
212  iss >> this->Mcurrentwid2.vang;
213  }
214  else if (key==ascii::keycalib)
215  {
216  iss >> this->Mcurrentwid2.calib;
217  }
218  else if (key==ascii::keycalper)
219  {
220  iss >> this->Mcurrentwid2.calper;
221  }
222  else if (key==ascii::keynstacks)
223  {
224  this->Mreadinfo=true;
225  iss >> this->Mcurrentinfo.nstacks;
226  }
227  else if (key==ascii::keyRECVX)
228  {
229  this->Mreadinfo=true;
230  iss >> this->Mcurrentinfo.cx;
231  }
232  else if (key==ascii::keyRECVY)
233  {
234  this->Mreadinfo=true;
235  iss >> this->Mcurrentinfo.cy;
236  }
237  else if (key==ascii::keyRECVZ)
238  {
239  this->Mreadinfo=true;
240  iss >> this->Mcurrentinfo.cz;
241  }
242  else if (key==ascii::keySRCEX)
243  {
244  this->Mreadsrce=true;
245  iss >> this->Mcurrentsrce.cx;
246  }
247  else if (key==ascii::keySRCEY)
248  {
249  this->Mreadsrce=true;
250  iss >> this->Mcurrentsrce.cy;
251  }
252  else if (key==ascii::keySRCEZ)
253  {
254  this->Mreadsrce=true;
255  iss >> this->Mcurrentsrce.cz;
256  }
257  else
258  {
259  if (key.length()==0)
260  {
261  DATRW_report_assert(key.length()>0,
262  "keyword is missing in header line\n" <<
263  "input line: " << Mcurrentline << "\n" <<
264  "key: " << key);
265  }
266  else
267  {
268  if (!Mnonfatal)
269  {
270  std::cerr << "Illegal keyword: " << key << std::endl;
271  }
272  // was not recognoized
274  false,
275  "iasciistream: header key not recognized\n"
276  "input line: " << Mcurrentline << "\n" <<
277  "key: " << key);
278  }
279  }
280  }
281  }
282  std::getline(Mis, this->Mcurrentline);
283  } // while ((this->Mcurrentline.substr(0,1)=="#") && Mis.good())
284  } // void iasciistream::readheader()
285 
286  /*----------------------------------------------------------------------*/
287 
289  {
290  this->newtrace();
291  if (this->Mreadfree) { this->settracefree(this->Mcurrentfree); }
292  if (this->Mreadinfo) { this->setinfo(this->Mcurrentinfo); }
293  if (this->Mreadsrce) { this->setsrce(this->Mcurrentsrce); }
294  this->setwid2(this->Mcurrentwid2);
295  } // void iasciistream::settraceheader()
296 
297  /*----------------------------------------------------------------------*/
298 
299  namespace ascii {
300 
301  namespace {
302 
303  /*! read a sequence of samples
304  * \ingroup group_ascii
305  *
306  * Read a sequence of samples being regarded as a contiguous trace.
307  *
308  * \param T type of sample value (double, float, int)
309  *
310  * \param is input stream to read from
311  * \param n expected number of samples
312  * \param firstline first line from input, which is already read
313  * \param series container to write samples to
314  * \param nonfatal errors are made nonfatal if true
315  * \return next input line
316  */
317  template<typename T>
318  std::string readsamples(std::istream& is,
319  const unsigned int& n,
320  const std::string& firstline,
321  typename aff::Series<T>& series,
322  const bool& nonfatal)
323  {
324  typedef typename aff::Series<T> Tmyseries;
325  std::string line=firstline;
326  if (n==0)
327  {
328  // we do not expect a specific number of samples
329  // read as many samples as can be found
330  typedef typename std::vector<Tmyseries> Tvecofrecorddata;
331  Tvecofrecorddata vecofrecorddata;
332  unsigned int nsamples=0;
333  unsigned int i=0;
334  const unsigned int bufsize=5000;
335  Tmyseries buffer(0,bufsize-1);
336  buffer=0;
337  // read data
338  while ((!(line.substr(0,1)=="#")) && is.good())
339  {
340  if (i==bufsize)
341  {
342  vecofrecorddata.push_back(buffer.copyout());
343  buffer=0;
344  i=0;
345  }
346  std::istringstream iss(line);
347  iss >> buffer(i);
348  std::getline(is, line);
349  ++i;
350  ++nsamples;
351  }
352  if (i>0)
353  {
354  vecofrecorddata.push_back(aff::subarray(buffer)(0,i-1));
355  }
356  // data read: now copy fragments to series container
357  typename Tvecofrecorddata::const_iterator I(vecofrecorddata.begin());
358  series=Tmyseries(0,nsamples-1);
359  nsamples=0;
360  while (I != vecofrecorddata.end())
361  {
362  Tmyseries dest
363  =aff::subarray(series)(nsamples,nsamples+I->size()-1);
364  dest.copyin(*I);
365  nsamples += I->size();
366  ++I;
367  }
368  }
369  else
370  {
371  // we expect a specfied number of samples
372  series=Tmyseries(n);
373  series=0;
374  unsigned int i=0;
375  while ((!(line.substr(0,1)=="#")) && is.good() && (i<n))
376  {
377  std::istringstream iss(line);
378  iss >> series(series.f()+i);
379  std::getline(is, line);
380  ++i;
381  }
383  (i==n),
384  "readsamples (ASCII): "
385  "found less samples than expected\n"
386  "expected: " << n << " " <<
387  "found: " << i);
388  }
389  return(line);
390  } // readsamples
391 
392  /*----------------------------------------------------------------------*/
393 
394  /*! read a sequence of samples
395  * \ingroup group_ascii
396  *
397  * Read a sequence of samples being regarded as a contiguous trace.
398  * This function essential performs the correct type conversion after
399  * reading the data with function readsamples().
400  *
401  * \param T type of sample value (double, float, int)
402  *
403  * \param is input stream to read from
404  * \param n expected number of samples
405  * \param firstline first line from input, which is already read
406  * \param series container to write samples to
407  * \param datatype expected type of data
408  * \param nonfatal errors are made nonfatal if true
409  * \return next input line
410  */
411  template<typename T>
412  std::string readany(std::istream& is,
413  const unsigned int& n,
414  const std::string& firstline,
415  typename aff::Series<T>& series,
416  const std::string& datatype,
417  const bool& nonfatal)
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  }
446 
447  } // namespace
448 
449  } // namespace ascii
450 
451  /*----------------------------------------------------------------------*/
452 
454  {
455  Tdseries retval;
456  this->Mcurrentline=ascii::readany(this->Mis,
457  this->Mcurrentwid2.nsamples,
458  this->Mcurrentline,
459  retval,
460  this->Mdatatype,
461  this->Mnonfatal);
462  this->Mcurrentwid2.nsamples=retval.size();
463  this->settraceheader();
464  this->readheader();
465  if (!this->Mis.good()) { this->setlast(); }
466  return(retval);
467  } // Tdseries iasciistream::dseries()
468 
469  /*----------------------------------------------------------------------*/
470 
472  {
473  Tfseries retval;
474  this->Mcurrentline=ascii::readany(this->Mis,
475  this->Mcurrentwid2.nsamples,
476  this->Mcurrentline,
477  retval,
478  this->Mdatatype,
479  this->Mnonfatal);
480  this->Mcurrentwid2.nsamples=retval.size();
481  this->settraceheader();
482  this->readheader();
483  if (!this->Mis.good()) { this->setlast(); }
484  return(retval);
485  } // Tfseries iasciistream::fseries()
486 
487  /*----------------------------------------------------------------------*/
488 
490  {
491  Tiseries retval;
492  this->Mcurrentline=ascii::readany(this->Mis,
493  this->Mcurrentwid2.nsamples,
494  this->Mcurrentline,
495  retval,
496  this->Mdatatype,
497  this->Mnonfatal);
498  this->Mcurrentwid2.nsamples=retval.size();
499  this->settraceheader();
500  this->readheader();
501  if (!this->Mis.good()) { this->setlast(); }
502  return(retval);
503  } // Tiseries iasciistream::iseries()
504 
505  /*----------------------------------------------------------------------*/
506 
508  {
509  if (this->Mcurrentwid2.nsamples==0)
510  {
511  while ((!(this->Mcurrentline.substr(0,1)=="#")) && Mis.good())
512  {
513  ++this->Mcurrentwid2.nsamples;
514  std::getline(Mis, this->Mcurrentline);
515  }
516  }
517  else
518  {
519  int i=0;
520  while ((!(this->Mcurrentline.substr(0,1)=="#")) && Mis.good()
521  && (i<this->Mcurrentwid2.nsamples))
522  {
523  std::getline(Mis, this->Mcurrentline);
524  ++i;
525  }
526  }
527  this->settraceheader();
528  this->readheader();
529  if (!this->Mis.good()) { this->setlast(); }
530  } // void iasciistream::skipseries()
531 
532  /*----------------------------------------------------------------------*/
533 
534  namespace ascii {
535 
536  namespace {
537 
538  /*!
539  * \ingroup group_ascii
540  * \todo
541  * replace with formatmodifiers::ModifierHelp
542  */
543  void explainmodifier(std::ostream& os,
544  const char* const key,
545  const char* const message)
546  {
547  os.width(14);
548  std::string keyval=key;
549  keyval += "=v: ";
550  os << std::left << std::setfill('.')
551  << keyval << " " << message << std::endl;
552  } // void explainmodifier
553 
554  /*----------------------------------------------------------------------*/
555 
556  /*!
557  * \ingroup group_ascii
558  * \todo
559  * replace with formatmodifiers::ModifierHelp
560  */
561  void explainmodifierflag(std::ostream& os,
562  const char* const key,
563  const char* const message)
564  {
565  os.width(14);
566  std::string keyval=key;
567  keyval += ": ";
568  os << std::left << std::setfill('.')
569  << keyval << " " << message << std::endl;
570  } // void explainmodifierflag
571 
572  } // namespace
573 
574  } // namespace ascii
575 
576  /*----------------------------------------------------------------------*/
577 
578  void iasciistream::help(std::ostream& os)
579  {
580  os <<
581  std::endl <<
582  "ASCII reading functions" << std::endl <<
583  "-----------------------" << std::endl <<
584  DATRW_IASCIISTREAM_CC_VERSION << std::endl <<
585  std::endl;
586  os <<
587  "This module reads seismic time series data in the raw\n"
588  "single column ASCII format. No header values are required\n"
589  "but all SFF header data can be provided. Header data not\n"
590  "present in the file can be set through format modifiers.\n"
591  "Header data neither given in the file nor in the format are\n"
592  "set to default values. The number of samples is determined from\n"
593  "actual numer of samples present in the file. If a number of samples\n"
594  "is defined in the header it is used as a maximum number of samples\n"
595  "to be read until the next trace begins.\n"
596  "Each line with a hash (#) in the first column is treated\n"
597  "as a header line. Each line with a double hash (##) in the\n"
598  "first two columns is treated as a free format comment. All\n"
599  "other lines are treated as ASCII data.\n"
600  << std::endl;
601  os <<
602  "Parameter values for header fields can be set in lines which\n"
603  "have a single hash (#) in the first column. The hash is expected\n"
604  "to be followed by a key ID, which can be either one of the\n"
605  "modifier keys listed below or can be \"" << ascii::keydata << "\".\n"
606  "The key has to be separated from the value by a single colon (:).\n"
607  "If you feel unsure, simply write a data file using the ASCII\n"
608  "output functions and have a look at the result.\n"
609  << std::endl;
610  os <<
611  "The data type can be selected by the key \""
612  << ascii::keydata << "\" and one of the values:\n";
613  os << " "; os.width(7);
614  os << std::left
615  << ascii::keydouble << ": for double precision data\n";
616  os << " "; os.width(7);
617  os << std::left
618  << ascii::keyfloat << ": for single precision data\n";
619  os << " "; os.width(7);
620  os << std::left
621  << ascii::keyint << ": for integer data\n"
622  "If no type is specified, the default will be "
623  << ascii::keydouble << "\n"
624  << std::endl;
625  os <<
626  "The ascii input stream can be controlled by format modifiers:\n";
628  "(WID2) set number of samples");
630  "(WID2) set sampling interval (seconds)");
632  "(WID2) set time of first sample; YYYY/MM/DD/hh/mm/ss.ssssss");
634  "(WID2) set channel ID");
636  "(WID2) set station ID");
638  "(WID2) set auxiliary ID");
640  "(WID2) set instrument type ID");
642  "(WID2) set calib value");
644  "(WID2) set calper value");
646  "(WID2) set hang value");
648  "(WID2) set vang value");
650  "(SRCE) set date and time of source; YYYY/MM/DD/hh/mm/ss.ssssss");
652  "(SRCE) set type of source");
654  "(SRCE) set x coordinate of source");
656  "(SRCE) set y coordinate of source");
658  "(SRCE) set z coordinate of source");
660  "(SRCE) set coordinate system of source");
662  "(INFO) set number of stacks");
664  "(INFO) set x coordinate of receiver");
666  "(INFO) set y coordinate of receiver");
668  "(INFO) set z coordinate of receiver");
670  "(INFO) set coordinate system of receiver");
671  os << "Further modifiers:\n";
673  "make errors non-fatal is possible (only a warning will be issued)");
674  } // void iasciistream::help(std::ostream& os)
675 
676 } // namespace datrw
677 
678 /* ----- END OF iasciistream.cc ----- */
const char *const keyinstype
key for WID2 line header field
Definition: ascii.cc:51
virtual Tiseries iseries()
const char *const keySRCEtype
key for SRCE line header field
Definition: ascii.cc:58
const char *const keydouble
key for DATA type header field
Definition: ascii.cc:73
const char *const keySRCEY
key for SRCE line header field
Definition: ascii.cc:60
const char *const keynonfatal
format modifier key
Definition: ascii.cc:75
::sff::INFO Mdefaultinfo
Definition: ascii.h:92
provide format modifiers (prototypes)
Cout convert(const typename Cin::Tcoc &data)
function template to convert a whole series
Definition: util.h:74
void setinfo(const sff::INFO &info)
Definition: datread.cc:121
aff::Series< float > Tfseries
Definition: types.h:46
virtual Tdseries dseries()
const char *const keyRECVY
key for INFO line header field
Definition: ascii.cc:65
std::string Mmodifier
format modifier
Definition: ascii.h:83
void explainmodifier(std::ostream &os, const char *const key, const char *const message)
std::string Mcurrentline
Definition: ascii.h:84
const char *const keydt
key for WID2 line header field
Definition: ascii.cc:46
static const std::ios_base::openmode openmode
Definition: ascii.h:78
handle data types and data type conversion (prototypes)
const char *const keyRECVCS
key for INFO line header field
Definition: ascii.cc:67
const char *const keyhang
key for WID2 line header field
Definition: ascii.cc:54
void setsrce(const sff::SRCE &srce)
Definition: datread.cc:129
aff::Series< double > Tdseries
Definition: types.h:45
::sff::SRCE Mcurrentsrce
Definition: ascii.h:96
iasciistream(std::istream &is, const std::string &modifier="", const bool &debug=false)
Definition: iasciistream.cc:61
const char *const keyint
key for DATA type header field
Definition: ascii.cc:71
std::string Mdatatype
Definition: ascii.h:85
const int nsamples
number of samples per minute block and channel
Definition: hpmodata.h:51
std::istream & Mis
Definition: datread.h:126
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
#define DATRW_assert_modifiers_are_recognized(S, F)
abort if user passed unused modifiers
#define DATRW_IASCIISTREAM_CC_VERSION
Definition: iasciistream.cc:42
const char *const keycalib
key for WID2 line header field
Definition: ascii.cc:52
const char *const keyauxid
key for WID2 line header field
Definition: ascii.cc:50
const char *const keychannel
key for WID2 line header field
Definition: ascii.cc:49
std::string trimws(std::string s)
remove leading and trailing whitespace
Definition: util.cc:129
Root namespace of library.
Definition: aalibdatrwxx.cc:16
::sff::WID2 Mdefaultwid2
Definition: ascii.h:87
::sff::FREE Mcurrentfree
Definition: ascii.h:90
const char *const keydate
key for WID2 line header field
Definition: ascii.cc:45
utilities used by more than one type of data reader (prototypes)
const char *const keynstacks
key for INFO line header field
Definition: ascii.cc:68
::sff::INFO Mcurrentinfo
Definition: ascii.h:93
void explainmodifierflag(std::ostream &os, const char *const key, const char *const message)
const char *const keySRCEdate
key for SRCE line header field
Definition: ascii.cc:57
#define DATRW_abort(M)
Abort and give a message.
Definition: error.h:101
const char *const keyRECVX
key for INFO line header field
Definition: ascii.cc:64
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
static void help(std::ostream &os=std::cout)
::sff::SRCE Mdefaultsrce
Definition: ascii.h:95
aff::Series< int > Tiseries
Definition: types.h:47
std::string clipstring(std::string &s, const std::string &delim)
strip substringStrips off first substring up to given delimiter. The string is passed as a reference ...
Definition: util.cc:105
const char *const keycalper
key for WID2 line header field
Definition: ascii.cc:53
#define DATRW_nonfatal_assert(F, C, M)
Macro to distinguish between fatal and non fatal assertions.
Definition: error.h:138
virtual void skipseries()
Class to handle format modifiersThis class is used to parse a format modifier string. Detailed instructions will be given upon request. For some hints have a look at tests/libdatrwxxtests.c.
const char *const keynsamples
key for WID2 line header field
Definition: ascii.cc:47
bool isset(const std::string &k) const
check if user provided this key
::sff::WID2 Mcurrentwid2
Definition: ascii.h:88
const char *const keySRCEX
key for SRCE line header field
Definition: ascii.cc:59
unsigned int Mnsamples
Definition: ascii.h:86
std::string readany(std::istream &is, const unsigned int &n, const std::string &firstline, typename aff::Series< T > &series, const std::string &datatype, const bool &nonfatal)
const char *const keyRECVZ
key for INFO line header field
Definition: ascii.cc:66
const char *const keySRCECS
key for SRCE line header field
Definition: ascii.cc:62
virtual Tfseries fseries()
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 keyvang
key for WID2 line header field
Definition: ascii.cc:55
std::string value(const std::string &k, const std::string &dev="false") const
function operator returns string
const char *const keystation
key for WID2 line header field
Definition: ascii.cc:48
#define DATRW_report_assert(C, M)
Check an assertion and report only.
Definition: error.h:120
const char *const keydata
key for DATA type header field
Definition: ascii.cc:70
const char *const keySRCEZ
key for SRCE line header field
Definition: ascii.cc:61
interface to write ASCII data (prototypes)
const char *const nonfatal
keywords for format modifiers