00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022
00023
00024 #ifndef SWKEY_H
00025 #define SWKEY_H
00026
00027 #include <swobject.h>
00028
00029 #include <defs.h>
00030
00031 #define KEYERR_OUTOFBOUNDS 1
00032
00033
00034
00035 class SW_POSITION
00036 {
00037 char pos;
00038 public:
00039 SW_POSITION (char ipos)
00040 {
00041 pos = ipos;
00042 }
00043 operator char ()
00044 {
00045 return pos;
00046 }
00047 };
00048
00049 #define POS_TOP ((char)1)
00050 #define POS_BOTTOM ((char)2)
00051
00052 #define TOP SW_POSITION(POS_TOP)
00053 #define BOTTOM SW_POSITION(POS_BOTTOM)
00054
00059 class SWDLLEXPORT SWKey:public SWObject
00060 {
00061 long index;
00062 static SWClass classdef;
00063 void init ();
00064
00065 protected:
00066 char *keytext;
00067 char persist;
00068 char error;
00069
00070 public:
00075 SWKey (const char *ikey = 0);
00076
00080 SWKey (SWKey const &k);
00081
00084 virtual ~ SWKey ();
00085
00090 virtual SWKey *clone () const;
00091
00098 char Persist () const;
00099
00108 char Persist (char ikey);
00109
00114 virtual char Error ();
00115
00120 virtual SWKey & operator = (const char *ikey);
00121
00126 virtual SWKey & operator = (const SWKey & ikey);
00127
00130 virtual operator const char *() const;
00131
00139 virtual int compare (const SWKey & ikey);
00140
00146 virtual bool operator == (const SWKey & ikey) { return !compare (ikey);
00147 }
00148
00154 virtual bool operator != (const SWKey & ikey)
00155 {
00156 return compare (ikey);
00157 }
00158
00162 virtual bool operator > (const SWKey & ikey)
00163 {
00164 return (compare (ikey) > 0);
00165 }
00166
00170 virtual bool operator < (const SWKey & ikey)
00171 {
00172 return (compare (ikey) < 0);
00173 }
00174
00178 virtual bool operator >= (const SWKey & ikey)
00179 {
00180 return (compare (ikey) > -1);
00181 }
00182
00186 virtual bool operator <= (const SWKey & ikey)
00187 {
00188 return (compare (ikey) < 1);
00189 }
00190
00193 virtual SWKey & operator = (SW_POSITION);
00194
00200 virtual SWKey & operator -= (int decrement);
00201
00207 virtual SWKey & operator += (int increment);
00208
00213 virtual SWKey & operator++ (int)
00214 {
00215 return *this += 1;
00216 }
00217
00222 virtual SWKey & operator-- (int)
00223 {
00224 return *this -= 1;
00225 }
00226
00227 virtual char Traversable ()
00228 {
00229 return 0;
00230 }
00231
00253 virtual long Index () const
00254 {
00255 return index;
00256 }
00257
00258 virtual long Index (long iindex)
00259 {
00260 index = iindex;
00261 return index;
00262 }
00263 };
00264
00265
00266 #endif