OpendTect-6_4  6.4
iopar.h
Go to the documentation of this file.
1 #ifndef iopar_h
2 #define iopar_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: 21-12-1995
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "namedobj.h"
17 #include "fixedstring.h"
18 #include "samplingdata.h"
19 #include "od_iosfwd.h"
20 
21 class BufferStringSet;
22 class SeparString;
23 class ascistream;
24 class ascostream;
25 class uiString;
26 
47 mExpClass(Basic) IOPar : public NamedObject
48 {
49 public:
50  IOPar(const char* nm=0);
51  IOPar(ascistream&);
52  IOPar(const IOPar&);
53  ~IOPar();
54  IOPar& operator =(const IOPar&);
55  inline bool operator ==( const IOPar& iop ) const
56  { return isEqual(iop); }
57  inline bool operator !=( const IOPar& iop ) const
58  { return !isEqual(iop); }
59 
60  int size() const;
61  int indexOf(const char* key) const;
62  inline bool isPresent( const char* ky ) const
63  { return indexOf(ky) >= 0; }
64 
65  inline bool isEmpty() const { return size() == 0; }
66  bool isEqual(const IOPar&,bool need_same_order=false) const;
67  FixedString getKey(int) const;
68  FixedString getValue(int) const;
69  bool setKey(int,const char*);
70  void setValue(int,const char*);
71 
72  inline bool hasKey( const char* s ) const { return isPresent(s); }
73  const char* findKeyFor(const char*,int nr=0) const;
75 
76  void remove(int);
77  void removeWithKey(const char* key);
78  void removeWithKeyPattern(const char* globexpression);
81 
82  void setEmpty();
84  void merge(const IOPar&);
86  void addFrom(const IOPar&);
88  static const char* compKey(const char*,const char*);
90  static const char* compKey(const char*,int);
92  static const char* compKey( const char* ky1, const OD::String& ky2 )
93  { return compKey(ky1,ky2.str()); }
94  IOPar* subselect(const char*) const;
96  IOPar* subselect(int) const;
98  IOPar* subselect( const OD::String& fs ) const
99  { return subselect( fs.str() ); }
100  void removeSubSelection(const char*);
102  void removeSubSelection(int);
104  void removeSubSelection( const OD::String& fs )
105  { removeSubSelection( fs.str() ); }
106  void mergeComp(const IOPar&,const char*);
108 
109 // GET functions
110 
111  const char* find(const char*) const;
113  FixedString operator[]( const char* ky ) const
114  { return FixedString( find(ky) ); }
115 
116  // Functions for getting 1,2,3 and 4 of the same type
117 #define mIOParDeclFns(type) \
118  bool get(const char*,type&) const; \
119  bool get(const char*,type&,type&) const; \
120  bool get(const char*,type&,type&,type&) const; \
121  bool get(const char*,type&,type&,type&,type&) const
122 
123  mIOParDeclFns(int);
127  mIOParDeclFns(float);
128  mIOParDeclFns(double);
129 #undef mIOParDeclFns
130  bool getYN(const char*,bool&) const;
131  bool getYN(const char*,bool&,bool&) const;
132  bool getYN(const char*,bool&,bool&,bool&) const;
133  bool getYN(const char*,bool&,bool&,bool&,bool&) const;
134  inline bool isTrue( const char* key ) const
135  { bool is = false; return getYN(key,is) && is; }
136  inline bool isFalse( const char* key ) const
137  { bool is = true; return getYN(key,is) && !is; }
138 
139  bool get(const char*,int&,int&,float&) const;
140 
141  bool get(const char*,TypeSet<int>&) const;
142  bool get(const char*,TypeSet<od_uint32>&) const;
143  bool get(const char*,TypeSet<od_int64>&) const;
144  bool get(const char*,TypeSet<od_uint64>&) const;
145  bool get(const char*,TypeSet<double>&) const;
146  bool get(const char*,TypeSet<float>&) const;
147 
148  bool get(const char*,BinID&) const;
149  bool get(const char*,TrcKey&) const;
150  bool get(const char*,Coord&) const;
151  bool get(const char*,Coord3&) const;
152  bool get(const char*,MultiID&) const;
153  bool get(const char*,Color&) const;
154  bool get(const char*,SeparString&) const;
155  bool get(const char*,uiString&) const;
156  bool get(const char*,BufferString&) const;
157  bool get(const char*,BufferString&,BufferString&) const;
158  bool get(const char*,BufferString&,BufferString&,
159  BufferString&) const;
160  bool get(const char*,BufferStringSet&) const;
161  template <class T>
162  bool get(const char*,Interval<T>&) const;
163  template <class T>
164  bool get(const char*,SamplingData<T>&) const;
165 
166  bool getPtr(const char*,void*&) const;
167 
168 #define mIOParDeclFns(type) \
169  bool getScaled(const char*,type&,type applied_scale, \
170  bool set_to_undef_if_not_found) const; \
171  bool getScaled(const char*,type&,type&,type,bool) const; \
172  bool getScaled(const char*,type&,type&,type&,type, \
173  bool) const; \
174  bool getScaled(const char*,type&,type&,type&,type&,type, \
175  bool) const
176  mIOParDeclFns(float);
177  mIOParDeclFns(double);
178 #undef mIOParDeclFns
179 
180 
181 // SET functions
182 
183  void set(const char* ky,const char* val);
185  void add(const char* ky,const char* val);
187  void add( const char* ky, const OD::String& val )
188  { add( ky, val.str() ); }
189  void update(const char* ky,const char* val);
192  // Functions for 1,2,3 and 4 of the same type
193 #define mIOParDeclFns(fnnm,type) \
194  void fnnm(const char*,type); \
195  void fnnm(const char*,type,type); \
196  void fnnm(const char*,type,type,type); \
197  void fnnm(const char*,type,type,type,type)
198 
199  mIOParDeclFns(set,int);
201  mIOParDeclFns(set,od_int64);
203  mIOParDeclFns(set,float);
204  mIOParDeclFns(set,double);
205  mIOParDeclFns(add,int);
207  mIOParDeclFns(add,od_int64);
209  mIOParDeclFns(add,float);
210  mIOParDeclFns(add,double);
211 #undef mIOParDeclFns
212 #define mIOParDeclYNFns(fnnm) \
213  void fnnm##YN(const char*,bool); \
214  void fnnm##YN(const char*,bool,bool); \
215  void fnnm##YN(const char*,bool,bool,bool); \
216  void fnnm##YN(const char*,bool,bool,bool,bool)
217  mIOParDeclYNFns(set);
218  mIOParDeclYNFns(add);
219 #undef mIOParDeclYNFns
220 
221  void set(const char*,int,int,float);
222  void setPtr(const char*,void*);
223 
224  void set(const char*,const char*,const char*);
225  void set(const char*,const char*,const char*,const char*);
226  void set(const char*,const BinID&);
227  void set(const char*,const TrcKey&);
228  void set(const char*,const Coord&);
229  void set(const char*,const Coord3&);
230  void set(const char*,const MultiID&);
231  void set(const char*,const Color&);
232  void set(const char*,const SeparString&);
233  void set(const char*,const uiString&);
234  void set(const char*,const OD::String&);
235  void set(const char*,const OD::String&,
236  const OD::String&);
237  void set(const char*,const OD::String&,
238  const OD::String&,
239  const OD::String&);
240  void set(const char*,const BufferStringSet&);
241  template <class T>
242  void set(const char*,const Interval<T>&);
243  template <class T>
244  void set(const char*,const SamplingData<T>&);
245 
246  void set(const char*,const TypeSet<int>&);
247  void set(const char*,const TypeSet<od_uint32>&);
248  void set(const char*,const TypeSet<od_int64>&);
249  void set(const char*,const TypeSet<od_uint64>&);
250  void set(const char*,const TypeSet<double>&);
251  void set(const char*,const TypeSet<float>&);
252 
253  void setToDateTime(const char* ky=0);
254  void setToUser(const char* ky=0);
255  void setStdCreationEntries();
256 
257 
258 // I/O functions
259 
260  // to/from string: 'serialisation'
261  void getFrom(const char*);
262  void getParsFrom(const char*);
263  void putTo(BufferString&) const;
264  void putParsTo(BufferString&) const;
265 
266  // to/from file
267  void getFrom(ascistream&);
268  void putTo(ascostream&) const;
269  bool read(const char* filename,const char* filetype,
270  bool chktype=false);
273  bool read(od_istream&,const char* filetype,
274  bool chktype=false);
275  bool write(const char* filename,const char* filetype) const;
278  bool write(od_ostream&,const char* filetyp) const;
279  int majorVersion() const { return majorversion_; }
281  int minorVersion() const { return minorversion_; }
283  int odVersion() const;
287  void dumpPretty(BufferString&) const;
288  void dumpPretty(od_ostream&) const;
289 
290  static const char* sKeyDumpPretty() { return "_pretty"; }
291  static const char* sKeyHdr() { return "->"; }
292  static const char* sKeySubHdr() { return "-->"; }
293 
294 protected:
295 
298 
301 
302 };
303 
304 
305 template <class T>
306 inline bool IOPar::get( const char* k, Interval<T>& i ) const
307 {
309  return si ? get( k, i.start, i.stop, si->step )
310  : get( k, i.start, i.stop );
311 }
312 
313 
314 template <class T>
315 inline void IOPar::set( const char* k, const Interval<T>& i )
316 {
317  mDynamicCastGet(const StepInterval<T>*,si,&i)
318  if ( si ) set( k, i.start, i.stop, si->step );
319  else set( k, i.start, i.stop );
320 }
321 
322 
323 template <class T>
324 inline bool IOPar::get( const char* k, SamplingData<T>& sd ) const
325 {
326  return get( k, sd.start, sd.step );
327 }
328 
329 
330 template <class T>
331 inline void IOPar::set( const char* k, const SamplingData<T>& sd )
332 {
333  set( k, sd.start, sd.step );
334 }
335 
336 
337 #endif
#define mExpClass(module)
Definition: commondefs.h:160
int size() const
T step
Definition: samplingdata.h:50
int minorVersion() const
Only set if read from file. Otherwise set to current.
Definition: iopar.h:281
#define mIOParDeclFns(type)
Definition: iopar.h:193
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
const char * str() const
Definition: odstring.h:48
static const char * sKeyHdr()
Definition: iopar.h:291
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
OD::String that holds an existing text string.
Definition: fixedstring.h:29
#define od_int64
Definition: plftypes.h:36
OpendTect standard ascii format file writing.
Definition: ascstream.h:32
bool isPresent(const char *ky) const
Definition: iopar.h:62
bool isFalse(const char *key) const
Definition: iopar.h:136
List encoded in a string.
Definition: separstr.h:33
Definition: uistring.h:89
A cartesian coordinate in 2D space.
Definition: coord.h:25
Set of BufferString objects.
Definition: bufstringset.h:28
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
bool get(const char *, int &) const
uiString & operator=(const uiString &)
no copy, ref counted
int majorVersion() const
Only set if read from file. Otherwise set to current.
Definition: iopar.h:279
Interval of values.
Definition: commontypes.h:31
OD class for stream read.
Definition: od_istream.h:24
bool hasKey(const char *s) const
Definition: iopar.h:72
IOPar * subselect(const OD::String &fs) const
Definition: iopar.h:98
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
#define od_uint32
Definition: plftypes.h:32
bool isEmpty() const
Definition: iopar.h:65
BufferStringSet & vals_
Definition: iopar.h:300
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
T start
Definition: samplingdata.h:49
Interval with step.
Definition: commontypes.h:33
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:131
const T * find(const ObjectSet< T > &os, const S &val)
Get const object in set.
Definition: objectset.h:183
OpendTect standard ascii format file reading.
Definition: ascstream.h:83
A cartesian coordinate in 3D space.
Definition: coord.h:72
void setEmpty()
#define od_uint64
Definition: plftypes.h:37
#define mIOParDeclYNFns(fnnm)
Definition: iopar.h:212
T stop
Definition: ranges.h:93
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:30
Object with a name.
Definition: namedobj.h:35
FixedString operator[](const char *ky) const
Definition: iopar.h:113
static const char * sKeyDumpPretty()
Definition: iopar.h:290
void add(const char *ky, const OD::String &val)
Definition: iopar.h:187
bool isTrue(const char *key) const
Definition: iopar.h:134
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
T start
Definition: ranges.h:92
static const char * compKey(const char *ky1, const OD::String &ky2)
Definition: iopar.h:92
Holds the fundamental sampling info: start and interval.
Definition: samplingdata.h:22
void removeSubSelection(const OD::String &fs)
Definition: iopar.h:104
Represents a unique trace position in one of the surveys that OpendTect is managing.
Definition: trckey.h:28
void set(const char *ky, const char *val)
int majorversion_
Definition: iopar.h:296
BufferStringSet & keys_
Definition: iopar.h:299
static const char * sKeySubHdr()
Definition: iopar.h:292
Compound key consisting of ints.
Definition: multiid.h:25
int minorversion_
Definition: iopar.h:297

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