OpendTect  6.3
compoundkey.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: 15-1-2000
9 ________________________________________________________________________
10 
11 -*/
12 
13 
14 #include "basicmod.h"
15 #include "bufstring.h"
16 
17 
21 mExpClass(Basic) CompoundKey : public OD::String
22 {
23 public:
24 
25  typedef int IdxType;
26 
27  inline CompoundKey( const char* s=0 ) { if ( s ) impl_ = s; }
28  inline CompoundKey( const CompoundKey& ck )
29  : impl_(ck.impl_) {}
30  inline CompoundKey& operator=( const char* s )
31  { impl_ = s; return *this;}
32  inline CompoundKey& operator+=(const char*);
33  inline bool operator==( const char* s ) const
34  { return impl_ == s; }
35  inline bool operator==( const CompoundKey& oth ) const
36  { return impl_ == oth.impl_; }
37  inline bool operator!=( const char* s ) const
38  { return impl_ != s; }
39  inline bool operator!=(const CompoundKey& u) const
40  { return impl_ != u.impl_; }
41  inline void setEmpty() { impl_.setEmpty(); }
42  inline bool isEmpty() const { return impl_.isEmpty();}
43  inline char* getCStr() { return impl_.getCStr(); }
44  inline operator const char*() const
45  { return buf(); }
46 
47  IdxType nrKeys() const;
48  BufferString key(IdxType) const;
49  void setKey(IdxType,const char*);
50  CompoundKey upLevel() const;
51  bool isUpLevelOf(const CompoundKey&) const;
52 
53 protected:
54 
56  char* fromKey(IdxType) const;
57  const char* getKeyPart(IdxType) const;
58 
59  virtual const char* gtBuf() const { return impl_.buf(); }
60  virtual const char* gtStr() const { return impl_.str(); }
61 
62 private:
63 
64  char* fetchKeyPart(IdxType,bool) const;
65 
66 };
67 
68 
69 inline CompoundKey& CompoundKey::operator +=( const char* s )
70 {
71  if ( !impl_.isEmpty() )
72  impl_.add( "." );
73  impl_.add( s );
74  return *this;
75 }
#define mExpClass(module)
Definition: commondefs.h:157
virtual const char * gtStr() const
Definition: compoundkey.h:60
const char * str() const
Definition: odstring.h:46
bool operator==(const CompoundKey &oth) const
Definition: compoundkey.h:35
CompoundKey & operator=(const char *s)
Definition: compoundkey.h:30
virtual const char * gtBuf() const
Definition: compoundkey.h:59
char * getCStr()
Definition: compoundkey.h:43
int IdxType
Definition: compoundkey.h:25
CompoundKey(const CompoundKey &ck)
Definition: compoundkey.h:28
bool isEmpty() const
Definition: compoundkey.h:42
const char * buf() const
Definition: odstring.h:45
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
bool isEmpty() const
Definition: odstring.h:49
Concatenated short keys separated by dots. Used for Object identifiers in the Object Manager...
Definition: compoundkey.h:21
bool operator==(const char *s) const
Definition: compoundkey.h:33
OpendTect.
Definition: commontypes.h:25
BufferString & add(char)
CompoundKey(const char *s=0)
Definition: compoundkey.h:27
CompoundKey & operator+=(const char *)
Definition: compoundkey.h:69
void setEmpty()
Definition: compoundkey.h:41
BufferString impl_
Definition: compoundkey.h:55
bool operator!=(const char *s) const
Definition: compoundkey.h:37
bool operator!=(const CompoundKey &u) const
Definition: compoundkey.h:39

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