OpendTect  6.6
datainterp.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H.Bril
8  Date: Nov 2000
9  Contents: Binary data interpretation
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 */
14 
15 #include "datachar.h"
16 #include "gendefs.h"
17 class od_istream;
18 
19 
20 #if defined(__msvc__) && (defined(GENERAL_EXPORTS) || defined(General_EXPORTS) )
21 # define mGenClass class dll_export
22 #else
23 # define mGenClass class
24 #endif
25 
35 template<class T>
37 {
38 public:
41  bool alsoifequal);
46  static DataInterpreter<T>* create(const char*,bool alsoifequal);
51  static DataInterpreter<T>* create(const IOPar& par,const char* key,
52  bool alsoifequal);
59  bool ignoreendianness=false);
61  void set(const DataCharacteristics&,
62  bool ignoreendianness=false);
66  { set( dc, false ); return *this; }
67 
68  bool needSwap() const;
69  void swap( void* buf, od_int64 bufsz_in_elements ) const
70  { (this->*swpfn)( buf, bufsz_in_elements );
71  const_cast<DataInterpreter<T>*>(this)->swpSwap(); }
72 
73  T get(od_istream&) const;
74  static T get(const DataInterpreter<T>*,od_istream&);
75  static bool get(const DataInterpreter<T>*,od_istream&,T&);
76  inline T get( const void* buf, od_int64 nr ) const
77  { return (this->*getfn)( buf, nr ); }
78  inline void put( void* buf, od_int64 nr, T t ) const
79  { (this->*putfn)( buf, nr, t ); }
80 
81  inline bool operator ==( const DataInterpreter& di ) const
82  { return di.getfn == getfn; }
83  inline bool operator !=( const DataInterpreter& di ) const
84  { return di.getfn != getfn; }
85  inline bool isSUCompat() const
86  { return getfn == &DataInterpreter::getF; }
87  int nrBytes() const;
89 
90 protected:
91 
92  void swap2(void*,od_int64) const;
93  void swap4(void*,od_int64) const;
94  void swap8(void*,od_int64) const;
95 
96  T getS1(const void*,od_int64) const;
97  T getS2(const void*,od_int64) const;
98  T getS4(const void*,od_int64) const;
99  T getS8(const void*,od_int64) const;
100  T getU1(const void*,od_int64) const;
101  T getU2(const void*,od_int64) const;
102  T getU4(const void*,od_int64) const;
103  T getF(const void*,od_int64) const;
104  T getD(const void*,od_int64) const;
105 
106  T getS2Ibm(const void*,od_int64) const;
107  T getS4Ibm(const void*,od_int64) const;
108  T getFIbm(const void*,od_int64) const;
109 
110  T getS2swp(const void*,od_int64) const;
111  T getS4swp(const void*,od_int64) const;
112  T getS8swp(const void*,od_int64) const;
113  T getU2swp(const void*,od_int64) const;
114  T getU4swp(const void*,od_int64) const;
115  T getFswp(const void*,od_int64) const;
116  T getDswp(const void*,od_int64) const;
117 
118  T getS2Ibmswp(const void*,od_int64) const;
119  T getS4Ibmswp(const void*,od_int64) const;
120  T getFIbmswp(const void*,od_int64) const;
121 
122  void putS1(void*,od_int64,T) const;
123  void putS2(void*,od_int64,T) const;
124  void putS4(void*,od_int64,T) const;
125  void putS8(void*,od_int64,T) const;
126  void putU1(void*,od_int64,T) const;
127  void putU2(void*,od_int64,T) const;
128  void putU4(void*,od_int64,T) const;
129  void putF(void*,od_int64,T) const;
130  void putD(void*,od_int64,T) const;
131 
132  void putS2Ibm(void*,od_int64,T) const;
133  void putS4Ibm(void*,od_int64,T) const;
134  void putFIbm(void*,od_int64,T) const;
135 
136  void putS2swp(void*,od_int64,T) const;
137  void putS4swp(void*,od_int64,T) const;
138  void putS8swp(void*,od_int64,T) const;
139  void putU2swp(void*,od_int64,T) const;
140  void putU4swp(void*,od_int64,T) const;
141  void putFswp(void*,od_int64,T) const;
142  void putDswp(void*,od_int64,T) const;
143 
144  void putS2Ibmswp(void*,od_int64,T) const;
145  void putS4Ibmswp(void*,od_int64,T) const;
146  void putFIbmswp(void*,od_int64,T) const;
147 
148  typedef T (DataInterpreter<T>::*GetFn)(const void*,od_int64) const;
149  typedef void (DataInterpreter<T>::*PutFn)(void*,od_int64,T) const;
150  typedef void (DataInterpreter<T>::*SwapFn)(void*,od_int64) const;
151  GetFn getfn;
152  PutFn putfn;
153  SwapFn swpfn;
154 
155  void swap0(void*,od_int64) const {}
156  T get0(const void*,od_int64) const { return 0; }
157  void put0(void*,od_int64,T) const {}
158  void swpSwap();
159 
160 };
161 
162 
DataInterpreter::swap2
void swap2(void *, od_int64) const
DataInterpreter::getDswp
T getDswp(const void *, od_int64) const
DataInterpreter::getFIbm
T getFIbm(const void *, od_int64) const
DataInterpreter::putFIbmswp
void putFIbmswp(void *, od_int64, T) const
DataInterpreter::putD
void putD(void *, od_int64, T) const
DataInterpreter::putS4Ibm
void putS4Ibm(void *, od_int64, T) const
datachar.h
DataInterpreter::putFswp
void putFswp(void *, od_int64, T) const
DataInterpreter::swpfn
SwapFn swpfn
Definition: datainterp.h:153
DataInterpreter::putS2
void putS2(void *, od_int64, T) const
DataInterpreter::put
void put(void *buf, od_int64 nr, T t) const
Definition: datainterp.h:78
DataInterpreter::putDswp
void putDswp(void *, od_int64, T) const
DataInterpreter::getD
T getD(const void *, od_int64) const
DataInterpreter::operator=
DataInterpreter< T > & operator=(const DataCharacteristics &dc)
Definition: datainterp.h:65
DataInterpreter::getS4Ibm
T getS4Ibm(const void *, od_int64) const
DataInterpreter::put0
void put0(void *, od_int64, T) const
Definition: datainterp.h:157
DataInterpreter::putS2swp
void putS2swp(void *, od_int64, T) const
od_int64
#define od_int64
Definition: plftypes.h:35
DataInterpreter::getU2
T getU2(const void *, od_int64) const
DataInterpreter::isSUCompat
bool isSUCompat() const
Definition: datainterp.h:85
od_istream
OD class for stream read common access to the std::cin.
Definition: od_istream.h:24
DataInterpreter::putS4Ibmswp
void putS4Ibmswp(void *, od_int64, T) const
DataInterpreter::putS8swp
void putS8swp(void *, od_int64, T) const
DataInterpreter::getS2Ibmswp
T getS2Ibmswp(const void *, od_int64) const
DataInterpreter::putU2
void putU2(void *, od_int64, T) const
DataInterpreter::putU4
void putU4(void *, od_int64, T) const
DataInterpreter::DataInterpreter
DataInterpreter(const DataCharacteristics &, bool ignoreendianness=false)
operator==
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:81
DataInterpreter
Byte-level data interpreter.
Definition: cbvswriter.h:21
DataInterpreter::get
T get(od_istream &) const
DataInterpreter::getU4
T getU4(const void *, od_int64) const
DataInterpreter::putS4
void putS4(void *, od_int64, T) const
DataInterpreter::getS8
T getS8(const void *, od_int64) const
DataInterpreter::swap8
void swap8(void *, od_int64) const
DataInterpreter::getS8swp
T getS8swp(const void *, od_int64) const
DataInterpreter::putF
void putF(void *, od_int64, T) const
DataInterpreter::getFswp
T getFswp(const void *, od_int64) const
DataInterpreter::putS4swp
void putS4swp(void *, od_int64, T) const
DataInterpreter::create
static DataInterpreter< T > create()
DataInterpreter::dataChar
DataCharacteristics dataChar() const
operator!=
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:90
DataInterpreter::create
static DataInterpreter< T > * create(const IOPar &par, const char *key, bool alsoifequal)
DataInterpreter::putfn
PutFn putfn
Definition: datainterp.h:152
gendefs.h
DataInterpreter::get
static T get(const DataInterpreter< T > *, od_istream &)
DataInterpreter::get
static bool get(const DataInterpreter< T > *, od_istream &, T &)
DataInterpreter::get
T get(const void *buf, od_int64 nr) const
Definition: datainterp.h:76
DataInterpreter::getU2swp
T getU2swp(const void *, od_int64) const
DataInterpreter::getU4swp
T getU4swp(const void *, od_int64) const
DataInterpreter::set
void set(const DataCharacteristics &, bool ignoreendianness=false)
use ignoreendianness when you pre-byteswap the data
Conv::set
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:27
DataInterpreter::needSwap
bool needSwap() const
DataInterpreter::swap4
void swap4(void *, od_int64) const
DataInterpreter::putU4swp
void putU4swp(void *, od_int64, T) const
DataInterpreter::getS4Ibmswp
T getS4Ibmswp(const void *, od_int64) const
DataInterpreter::getF
T getF(const void *, od_int64) const
DataInterpreter::getS2swp
T getS2swp(const void *, od_int64) const
DataInterpreter::create
static DataInterpreter< T > * create(const DataCharacteristics &, bool alsoifequal)
DataInterpreter::swap
void swap(void *buf, od_int64 bufsz_in_elements) const
Definition: datainterp.h:69
DataInterpreter::swap0
void swap0(void *, od_int64) const
Definition: datainterp.h:155
DataInterpreter::getS1
T getS1(const void *, od_int64) const
DataInterpreter::nrBytes
int nrBytes() const
DataInterpreter::getS2
T getS2(const void *, od_int64) const
DataInterpreter::putU2swp
void putU2swp(void *, od_int64, T) const
DataInterpreter::putS1
void putS1(void *, od_int64, T) const
DataInterpreter::DataInterpreter
DataInterpreter(const DataInterpreter< T > &)
DataInterpreter::putU1
void putU1(void *, od_int64, T) const
mGenClass
#define mGenClass
Definition: datainterp.h:23
DataInterpreter::create
static DataInterpreter< T > * create(const char *, bool alsoifequal)
DataInterpreter::getS4
T getS4(const void *, od_int64) const
DataInterpreter::swpSwap
void swpSwap()
DataInterpreter::getFIbmswp
T getFIbmswp(const void *, od_int64) const
DataInterpreter::getS2Ibm
T getS2Ibm(const void *, od_int64) const
DataInterpreter::putS2Ibmswp
void putS2Ibmswp(void *, od_int64, T) const
DataInterpreter::get0
T get0(const void *, od_int64) const
Definition: datainterp.h:156
DataInterpreter::getU1
T getU1(const void *, od_int64) const
DataInterpreter::operator=
DataInterpreter< T > & operator=(const DataInterpreter< T > &)
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
DataInterpreter::getS4swp
T getS4swp(const void *, od_int64) const
DataInterpreter::putS8
void putS8(void *, od_int64, T) const
DataCharacteristics
byte-level data characteristics of stored data.
Definition: datachar.h:37
DataInterpreter::putS2Ibm
void putS2Ibm(void *, od_int64, T) const
DataInterpreter::getfn
GetFn getfn
Definition: datainterp.h:151
DataInterpreter::putFIbm
void putFIbm(void *, od_int64, T) const

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021