DATRW++ library: seismic data I/O with multiple formats
ibinstream.h
Go to the documentation of this file.
1 /*! \file ibinstream.h
2  * \brief basic binary input stream (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 10/11/2011
8  *
9  * basic binary input stream (prototypes)
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  * - 10/11/2011 V1.0 Thomas Forbriger
32  *
33  * ============================================================================
34  */
35 
36 // include guard
37 #ifndef DATRW_IBINSTREAM_H_VERSION
38 
39 #define DATRW_IBINSTREAM_H_VERSION \
40  "DATRW_IBINSTREAM_H V1.0 "
41 
42 #include <iostream>
43 #include <fstream>
44 #include <string>
45 #include <libtime++.h>
46 #include <datrwxx/types.h>
47 #include <sffxx.h>
48 
49 namespace datrw {
50 
51  namespace binary {
52 
53  /*! \brief stream like class for binary input of basic types and classes
54  * \ingroup group_binary
55  */
56  class ibinstream {
57  public:
58  ibinstream(std::istream& is,
59  const char* const magic,
60  const bool& debug=false);
61  void read(char& v);
62  void read(short& v);
63  void read(int& v);
64  void read(unsigned int& v);
65  void read(double& v);
66  void read(float& v);
67  void read(std::string& v);
68  void read(libtime::TAbsoluteTime& v);
69  void read(::sff::FREE& v);
70  void read(::sff::WID2& v);
71  void read(::sff::SRCE& v);
72  void read(::sff::INFO& v);
73  void read(Tdseries& v);
74  void read(Tfseries& v);
75  void read(Tiseries& v);
76  unsigned int skipdseries();
77  unsigned int skipfseries();
78  unsigned int skipiseries();
79  private:
80  std::istream& Mis;
81  bool Mswap;
82  bool Mdebug;
83  }; // class ibinstream
84 
85  /*----------------------------------------------------------------------*/
86 
87  /*! \brief input operator for basic types and classes
88  * \ingroup group_binary
89  */
90  template<class C>
92  {
93  ibs.read(v); return(ibs);
94  } // ibinstream& operator>>(ibinstream& ibs, C& v)
95 
96  } // namespace binary
97 
98 } // namespace datrw
99 
100 #endif // DATRW_IBINSTREAM_H_VERSION (includeguard)
101 
102 /* ----- END OF ibinstream.h ----- */
internal data types (prototypes)
aff::Series< float > Tfseries
Definition: types.h:46
ibinstream(std::istream &is, const char *const magic, const bool &debug=false)
Definition: ibinstream.cc:49
const char *const magic
magic number to identify file type and bytesex
Definition: binary.cc:53
unsigned int skipfseries()
Definition: ibinstream.cc:289
ibinstream & operator>>(ibinstream &ibs, C &v)
input operator for basic types and classes
Definition: ibinstream.h:91
aff::Series< double > Tdseries
Definition: types.h:45
std::istream & Mis
Definition: ibinstream.h:80
unsigned int skipdseries()
Definition: ibinstream.cc:275
Root namespace of library.
Definition: aalibdatrwxx.cc:16
aff::Series< int > Tiseries
Definition: types.h:47
stream like class for binary input of basic types and classes
Definition: ibinstream.h:56
unsigned int skipiseries()
Definition: ibinstream.cc:303