Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

swkey.h

00001 /******************************************************************************
00002  *  swkey.h     - code for base class 'swkey'.  swkey is the basis for all
00003  *                              types of keys for indexing into modules (e.g. verse, word,
00004  *                              place, etc.)
00005  *
00006  * $Id: swkey.h-source.html,v 1.10 2001/05/25 10:44:22 jansorg Exp $
00007  *
00008  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00009  *      CrossWire Bible Society
00010  *      P. O. Box 2528
00011  *      Tempe, AZ  85280-2528
00012  *
00013  * This program is free software; you can redistribute it and/or modify it
00014  * under the terms of the GNU General Public License as published by the
00015  * Free Software Foundation version 2.
00016  *
00017  * This program is distributed in the hope that it will be useful, but
00018  * WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * General Public License for more details.
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 // For use with = operator to position key.
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

Generated at Thu May 24 19:50:26 2001 for The Sword Project by doxygen1.1.5 written by Dimitri van Heesch, © 1997-2000