DATRW++ library: seismic data I/O with multiple formats
binary.cc
Go to the documentation of this file.
1 /*! \file binary.cc
2  * \brief write raw binary data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 24/02/2010
8  *
9  * write raw binary data (implementation)
10  *
11  * Copyright (c) 2010 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  * - 24/02/2010 V1.0 Thomas Forbriger
32  *
33  * ============================================================================
34  */
35 #define DATRW_BINARY_CC_VERSION \
36  "DATRW_BINARY_CC V1.0 "
37 
38 #include <datrwxx/binary.h>
39 #include <datrwxx/error.h>
40 
41 namespace datrw {
42 
43  /*! \brief Format properties
44  * \ingroup group_binary
45  * @{
46  */
47  const bool binary::isbinary=false;
48  const char* const binary::streamID="bin";
49  /**@}*/
50 
51  namespace binary{
52 
53  const char* const magic="TBIN";
54  const short version=1;
55 
56  /*----------------------------------------------------------------------*/
57 
58  void checkfileflags(const char& flags)
59  {
60  DATRW_assert(!((flags & Fsrce) && (flags & Finfo)),
61  "ERROR: flags indicate INFO and SRCE at the same time");
62  }
63 
64  /*----------------------------------------------------------------------*/
65 
66  void checktraceflags(const char& flags)
67  {
68  checkfileflags(flags);
69  unsigned int ntypes=0;
70  if (flags & Fdouble) { ++ntypes; }
71  if (flags & Ffloat) { ++ntypes; }
72  if (flags & Fint) { ++ntypes; }
73  DATRW_assert(ntypes == 1,
74  "ERROR: flags must indicate exactly one data type");
75  }
76 
77  } // namespace binary
78 
79 } // namespace datrw
80 
81 /* ----- END OF binary.cc ----- */
const char *const streamID
Format properties.
Definition: binary.cc:48
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
void checktraceflags(const char &flags)
abort if trace flags are inconsistent
Definition: binary.cc:66
void checkfileflags(const char &flags)
abort if file flags are inconsistent
Definition: binary.cc:58
trace has INFO header
Definition: binary.h:81
write raw binary data (prototypes)
const char *const magic
magic number to identify file type and bytesex
Definition: binary.cc:53
exception class declaration for libdatrwxx (prototypes)
trace has int data
Definition: binary.h:84
trace has SRCE header
Definition: binary.h:79
const short version
a version number for files - just in case
Definition: binary.cc:54
trace has float data
Definition: binary.h:83
Root namespace of library.
Definition: aalibdatrwxx.cc:16
trace has double data
Definition: binary.h:82
const bool isbinary
Format properties.
Definition: binary.cc:47