DATRW++ library: seismic data I/O with multiple formats
obinstream.h
Go to the documentation of this file.
1 /*! \file obinstream.h
2  * \brief basic binary output stream (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 10/11/2011
8  *
9  * basic binary output 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_OBINSTREAM_H_VERSION
38 
39 #define DATRW_OBINSTREAM_H_VERSION \
40  "DATRW_OBINSTREAM_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 binary output for basic types and classes
54  * \ingroup group_binary
55  */
56  class obinstream {
57  public:
58  obinstream(std::ostream& os,
59  const char* const magic,
60  const bool& debug=false);
61  void write(const char& v);
62  void write(const short& v);
63  void write(const int& v);
64  void write(const unsigned int& v);
65  void write(const double& v);
66  void write(const float& v);
67  void write(const std::string& v);
68  void write(const libtime::TAbsoluteTime& v);
69  void write(const ::sff::FREE& v);
70  void write(const ::sff::WID2& v);
71  void write(const ::sff::SRCE& v);
72  void write(const ::sff::INFO& v);
73  void write(const Tdseries::Tcoc& v);
74  void write(const Tfseries::Tcoc& v);
75  void write(const Tiseries::Tcoc& v);
76  private:
77  std::ostream& Mos;
78  bool Mdebug;
79  }; // class obinstream
80 
81  /*----------------------------------------------------------------------*/
82 
83  /*! \brief output operator for basic types and classes
84  * \ingroup group_binary
85  */
86  template<class C>
87  obinstream& operator<<(obinstream& obs, const C& v)
88  {
89  obs.write(v); return(obs);
90  } // obinstream& operator<<(obinstream& obs, const C& v)
91 
92  } // namespace binary
93 
94 } // namespace datrw
95 
96 #endif // DATRW_OBINSTREAM_H_VERSION (includeguard)
97 
98 /* ----- END OF obinstream.h ----- */
internal data types (prototypes)
const char *const magic
magic number to identify file type and bytesex
Definition: binary.cc:53
binary output for basic types and classes
Definition: obinstream.h:56
void write(const char &v)
Definition: obinstream.cc:59
Root namespace of library.
Definition: aalibdatrwxx.cc:16
obinstream(std::ostream &os, const char *const magic, const bool &debug=false)
Definition: obinstream.cc:49
std::ostream & Mos
Definition: obinstream.h:77
obinstream & operator<<(obinstream &obs, const C &v)
output operator for basic types and classes
Definition: obinstream.h:87