DATRW++ library: seismic data I/O with multiple formats
readtfascii.h
Go to the documentation of this file.
1 /*! \file readtfascii.h
2  * \brief read data obtained in ASCII (any2ascii) from T. Forbriger
3  * \brief (prototypes)
4  *
5  * ----------------------------------------------------------------------------
6  *
7  * \author Daniel Armbruster
8  * \date 05/10/2010
9  *
10  * Purpose: read data obtained in ASCII (any2ascii) from T. Forbriger
11  * (prototypes)
12  *
13  * ----
14  * This file is part of libdatrwxx.
15  *
16  * libdatrwxx is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * libdatrwxx is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with libdatrwxx. If not, see <http://www.gnu.org/licenses/>.
28  * ----
29  *
30  * Copyright (c) 2010 by Daniel Armbruster
31  *
32  * REVISIONS and CHANGES
33  * 05/10/2010 V0.1 Daniel Armbruster
34  *
35  * ============================================================================
36  */
37 
38 // include guard
39 #ifndef DATRW_READTFASCII_H_VERSION
40 
41 #define DATRW_READTFASCII_H_VERSION \
42  "DATRW_READTFASCII_H V0.1 "
43 
44 #include<iostream>
45 #include<string>
46 #include<sffxx.h>
47 
48 namespace datrw {
49 
50  /*! \brief all functions, classes, etc. to read data format of T.Forbriger's
51  * brief any2ascii
52  *
53  * \defgroup group_tfascii Reading module for: output of any2ascii
54  *
55  */
56 
57  /*! \brief all functions, classes, etc. to read data format of T.Forbriger's
58  * any2ascii
59  *
60  * \ingroup group_tfascii
61  */
62  namespace tfascii {
63  /*! \brief contains a few helper functions to extract data while reading
64  * \brief a file
65  */
66  namespace helper {
67  /*--------------------------------------------------------------------*/
68  //! split given string
69  /*!
70  This function will split a line after the following scheme:\n
71  number of samples: 1000 m
72  will be converted into:\n
73  1000
74 
75  \param line reference to the line which will be splitted
76  \param unit if a value has a unit or not
77 
78  */
79  void extractvalue(std::string& line, bool unit = false);
80  //! splits a given string after the colon
81  /*!
82  This helper function implements the same functionality as
83  TfasciiContainer::extractvalue. The only difference is that now
84  a string will be splitted after colon.
85 
86  \param line string which will be splitted after its colon
87  */
88  void extract(std::string& line);
89 
90  } // namespace helper
91 
92  /*----------------------------------------------------------------------*/
93  //! name of the stream
94  extern const char* const streamname;
95 
96  /*----------------------------------------------------------------------*/
97  //! holds the fileheader data
98  struct FileHeader {
100  ::sff::FREE filefree;
101  ::sff::SRCE srce;
102  };
103 
104  /*----------------------------------------------------------------------*/
105  //! holds the traceheader data
106  struct TraceHeader {
108  ::sff::WID2 wid2;
109  ::sff::FREE tracefree;
110  ::sff::INFO info;
111  };
112 
113  /*----------------------------------------------------------------------*/
114  //! read the complete fileheader
115  /*!
116  \param is the input stream
117  \param verbose for verbose output or not
118  \return the FileHeader of the data
119 
120  */
121  FileHeader readfileheader(std::istream& is, const bool& verbose = false);
122 
123  /*----------------------------------------------------------------------*/
124  //! read the complete traceheader
125  /*!
126  \param is the input stream
127  \param verbose for verbose output or not
128  \return the TraceHeader of the data
129 
130  */
131  TraceHeader readtraceheader(std::istream& is, const bool& verbose = false);
132 
133  /*----------------------------------------------------------------------*/
134  //! function to print online help
135  void help(std::ostream& os=std::cout);
136 
137  } // namespace tfascii
138 
139 } // namespace datrw
140 
141 
142 #endif // DATRW_READTFASCII_H_VERSION (includeguard)
143 
144 
145 /* ----- END OF readtfascii.h ----- */
FileHeader readfileheader(std::istream &is, const bool &verbose)
read the complete fileheader
Definition: readtfascii.cc:78
holds the traceheader data
Definition: readtfascii.h:106
const char *const streamname
name of the stream
Definition: readtfascii.cc:75
void extract(std::string &line)
splits a given string after the colon
Definition: readtfascii.cc:67
TraceHeader readtraceheader(std::istream &is, const bool &verbose)
read the complete traceheader
Definition: readtfascii.cc:165
Root namespace of library.
Definition: aalibdatrwxx.cc:16
holds the fileheader data
Definition: readtfascii.h:98
void help(std::ostream &os)
function to print online help
Definition: readtfascii.cc:287
void extractvalue(std::string &line, bool unit)
split given string
Definition: readtfascii.cc:53