00001 #ifndef compoundkey_h
00002 #define compoundkey_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef general_h
00017 #include <general.h>
00018 #endif
00019 #include <stdlib.h>
00020 #include <iostream>
00021
00032 mClass CompoundKey
00033 {
00034 public:
00035
00036 inline CompoundKey( const char* s=0 ) { if ( s ) id_ = s; }
00037 inline CompoundKey( const CompoundKey& ck )
00038 : id_(ck.id_) {}
00039 inline CompoundKey& operator=(const char* s) {id_ = s; return *this;}
00040 inline CompoundKey& operator+=(const char*);
00041 inline bool operator==(const char* s) const { return id_ == s; }
00042 inline bool operator==(const CompoundKey& u) const
00043 { return id_ == u.id_; }
00044 inline bool operator!=(const char* s) const { return id_ != s; }
00045 inline bool operator!=(const CompoundKey& u) const
00046 { return id_ != u.id_; }
00047 inline void setEmpty() { id_.setEmpty(); }
00048 inline bool isEmpty() const { return id_.isEmpty();}
00049 inline char* buf() { return id_.buf(); }
00050 inline const char* buf() const { return id_.buf(); }
00051 inline operator const char*() const { return buf(); }
00052
00053 int nrKeys() const;
00054 BufferString key(int) const;
00055 void setKey(int,const char*);
00056 CompoundKey upLevel() const;
00057 bool isUpLevelOf(const CompoundKey&) const;
00058
00059 virtual bool matchGE(const char*) const;
00060
00061 protected:
00062
00063 BufferString id_;
00064 char* fromKey(int,bool cptobuf=false) const;
00065 friend std::istream& operator >>(std::istream&,CompoundKey&);
00066
00067 };
00068
00069
00070 inline CompoundKey& CompoundKey::operator +=( const char* s )
00071 {
00072 if ( !id_.isEmpty() ) id_ += ".";
00073 id_ += s;
00074 return *this;
00075 }
00076
00077
00078 #endif