DATRW++ library: seismic data I/O with multiple formats
ascii.h
Go to the documentation of this file.
1 /*! \file ascii.h
2  * \brief interface to write ASCII data (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 11/04/2006
8  *
9  * interface to write ASCII data (prototypes)
10  *
11  * Copyright (c) 2006 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  * - 11/04/2006 V1.0 Thomas Forbriger
32  * - 23/08/2012 V1.1 output stream supports modifiers
33  * - 18/11/2016 V1.2 use debug flag in base class
34  *
35  * ============================================================================
36  */
37 
38 // include guard
39 #ifndef DATRW_ASCII_H_VERSION
40 
41 #define DATRW_ASCII_H_VERSION \
42  "DATRW_ASCII_H V1.2"
43 
44 #include<datrwxx/datread.h>
45 #include<datrwxx/datwrite.h>
46 
47 namespace datrw {
48 
49  /*! \brief internals of the ascii I/O module
50  *
51  * \ingroup group_ascii
52  */
53  namespace ascii {
54 
55  extern const bool isbinary;
56  extern const char* const streamID;
57 
58  } // namespace ascii
59 
60  /*----------------------------------------------------------------------*/
61 
62  /*! \brief class to read ascii data
63  *
64  * \ingroup group_ascii
65  */
66  class iasciistream: public idatstream {
67  public:
68  typedef idatstream Tbase;
69  iasciistream(std::istream& is,
70  const std::string& modifier="",
71  const bool& debug=false);
72  virtual ~iasciistream() { }
73  virtual Tdseries dseries();
74  virtual Tfseries fseries();
75  virtual Tiseries iseries();
76  virtual void skipseries();
77  static void help(std::ostream& os=std::cout);
78  static const std::ios_base::openmode openmode;
79  private:
80  void settraceheader();
81  void readheader();
82  bool Mnonfatal;
83  std::string Mmodifier; //!< format modifier
84  std::string Mcurrentline;
85  std::string Mdatatype;
86  unsigned int Mnsamples;
87  ::sff::WID2 Mdefaultwid2;
88  ::sff::WID2 Mcurrentwid2;
89  bool Mreadfree;
90  ::sff::FREE Mcurrentfree;
91  bool Mreadinfo;
92  ::sff::INFO Mdefaultinfo;
93  ::sff::INFO Mcurrentinfo;
94  bool Mreadsrce;
95  ::sff::SRCE Mdefaultsrce;
96  ::sff::SRCE Mcurrentsrce;
97  }; // class iasciistream
98 
99  /*----------------------------------------------------------------------*/
100 
101  /*! \brief class to write ascii data
102  *
103  * \ingroup group_ascii
104  */
105  class oasciistream: public odatstream {
106  public:
107  typedef odatstream Tbase;
108  oasciistream(std::ostream& os,
109  const std::string& modifier="",
110  const bool& debug=false);
111  inline virtual ~oasciistream() { }
112  static void help(std::ostream& os=std::cout);
113  static const std::ios_base::openmode openmode;
114  protected:
115  virtual void writefileheader();
116  virtual void writetrace(const Tdseries::Tcoc& series);
117  virtual void writetrace(const Tfseries::Tcoc& series);
118  virtual void writetrace(const Tiseries::Tcoc& series);
119  private:
120  void writetraceheader(const unsigned int& n, const char* type);
121  unsigned int Mprecision; //!< floating point format precision
122  }; // class oasciistream
123 
124 } // namespace datrw
125 
126 #endif // DATRW_ASCII_H_VERSION (includeguard)
127 
128 /* ----- END OF ascii.h ----- */
virtual Tiseries iseries()
unsigned int Mprecision
floating point format precision
Definition: ascii.h:121
idatstream Tbase
Definition: ascii.h:68
::sff::INFO Mdefaultinfo
Definition: ascii.h:92
aff::Series< float > Tfseries
Definition: types.h:46
virtual Tdseries dseries()
std::string Mmodifier
format modifier
Definition: ascii.h:83
std::string Mcurrentline
Definition: ascii.h:84
static const std::ios_base::openmode openmode
Definition: ascii.h:78
odatstream Tbase
Definition: ascii.h:107
virtual void writetrace(const Tdseries::Tcoc &series)
write double data
static const std::ios_base::openmode openmode
Definition: ascii.h:113
static void help(std::ostream &os=std::cout)
Definition: oasciistream.cc:73
aff::Series< double > Tdseries
Definition: types.h:45
::sff::SRCE Mcurrentsrce
Definition: ascii.h:96
virtual ~oasciistream()
Definition: ascii.h:111
iasciistream(std::istream &is, const std::string &modifier="", const bool &debug=false)
Definition: iasciistream.cc:61
std::string Mdatatype
Definition: ascii.h:85
bool debug()
indicate debug mode
Definition: datwrite.h:145
bool debug()
indicate debug mode
Definition: datread.h:116
virtual ~iasciistream()
Definition: ascii.h:72
Root namespace of library.
Definition: aalibdatrwxx.cc:16
::sff::WID2 Mdefaultwid2
Definition: ascii.h:87
::sff::FREE Mcurrentfree
Definition: ascii.h:90
virtual void writefileheader()
actually write the file header
Definition: oasciistream.cc:91
::sff::INFO Mcurrentinfo
Definition: ascii.h:93
oasciistream(std::ostream &os, const std::string &modifier="", const bool &debug=false)
Definition: oasciistream.cc:57
const bool isbinary
Format properties.
Definition: asciiformat.cc:46
static void help(std::ostream &os=std::cout)
class to read ascii data
Definition: ascii.h:66
::sff::SRCE Mdefaultsrce
Definition: ascii.h:95
aff::Series< int > Tiseries
Definition: types.h:47
virtual void skipseries()
const char *const streamID
Format properties.
Definition: asciiformat.cc:47
void writetraceheader(const unsigned int &n, const char *type)
::sff::WID2 Mcurrentwid2
Definition: ascii.h:88
unsigned int Mnsamples
Definition: ascii.h:86
virtual Tfseries fseries()
class to write ascii data
Definition: ascii.h:105
generic interface definition (prototypes)