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

versekey.h

00001 /******************************************************************************
00002  *  versekey.h - code for class 'versekey'- a standard Biblical verse key
00003  *
00004  * $Id: versekey_h-source.html,v 1.4 2001/10/05 20:45:22 mgruner Exp $
00005  *
00006  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00007  *      CrossWire Bible Society
00008  *      P. O. Box 2528
00009  *      Tempe, AZ  85280-2528
00010  *
00011  * This program is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU General Public License as published by the
00013  * Free Software Foundation version 2.
00014  *
00015  * This program is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  */
00021 
00022 
00023 #ifndef VERSEKEY_H
00024 #define VERSEKEY_H
00025 
00026 #include <swkey.h>
00027 #include <swmacs.h>
00028 #include <listkey.h>
00029 
00030 #include <defs.h>
00031 
00032 #define POS_MAXVERSE ((char)3)
00033 #define POS_MAXCHAPTER ((char)4)
00034 #define POS_MAXBOOK ((char)5)
00035 
00036 #define MAXVERSE SW_POSITION(POS_MAXVERSE)
00037 #define MAXCHAPTER SW_POSITION(POS_MAXCHAPTER)
00038 #define MAXBOOK SW_POSITION(POS_MAXBOOK)
00039 
00040 struct sbook
00041 {
00044   const char *name;
00047   unsigned char chapmax;
00050   int *versemax;
00051 };
00052 
00053 struct abbrev
00054 {
00055   const char *ab;
00056   int book;
00057 };
00058 
00059 
00060 class SWLocale;
00061 
00066 class SWDLLEXPORT VerseKey:public SWKey
00067 {
00068   class LocaleCache
00069   {
00070   public:
00071     char *name;
00072     unsigned int abbrevsCnt;
00073     SWLocale *locale;
00074       LocaleCache ()
00075     {
00076       name = 0;
00077       abbrevsCnt = 0;
00078       locale = 0;
00079     }
00080      virtual ~LocaleCache ()
00081     {
00082       if (name)
00083         delete[]name;
00084     }
00085   };
00086 
00087   static SWClass classdef;
00088 
00089   static long *offsets[2][2];
00090   static int offsize[2][2];
00093   static int instance;
00094   static struct sbook otbooks[];
00095   static struct sbook ntbooks[];
00096   static long otbks[];
00097   static long otcps[];
00098   static long ntbks[];
00099   static long ntcps[];
00100   static int vm[];
00101   static LocaleCache localeCache;
00102   ListKey internalListKey;
00103 
00104   const struct abbrev *abbrevs;
00105   int abbrevsCnt;
00108   char testament;
00109   mutable char book;
00110   mutable int chapter;
00111   mutable int verse;
00114   char autonorm;
00117   char headings;
00118 
00119   int getBookAbbrev (char *abbr);
00120   void initBounds () const;
00123   void initstatics ();
00126   void init ();
00131   void freshtext () const;
00135   virtual char parse ();
00144   int findindex (long *array, int size, long value);
00145   mutable VerseKey *lowerBound, *upperBound;
00146 
00147 public:
00148   static const char builtin_BMAX[2];
00149   static struct sbook *builtin_books[2];
00150   static const struct abbrev builtin_abbrevs[];
00151   const char *BMAX;
00152   struct sbook **books;
00153 
00160   VerseKey (const char *ikey = 0);
00161   
00168   VerseKey (const SWKey * ikey);
00169   
00176   VerseKey (const char *min, const char *max);
00177   
00183   VerseKey (VerseKey const &k);
00184   
00188   virtual ~ VerseKey ();
00189 
00196   VerseKey & LowerBound (const char *lb);
00197   
00203   VerseKey & UpperBound (const char *ub);
00204   
00208   VerseKey & LowerBound ()const;
00209   
00213   VerseKey & UpperBound ()const;
00214   
00217   void ClearBounds ();
00218   
00222   virtual SWKey *clone () const;
00223   
00227   virtual const char *getText() const;
00228   virtual void setText(const char *ikey) { SWKey::setText(ikey); parse (); }
00229   virtual void copyFrom(const SWKey & ikey);
00230   
00233   virtual void copyFrom(const VerseKey & ikey);
00234   
00240   virtual void setPosition(SW_POSITION);
00241   
00247   virtual void decrement(int step);
00248   
00254   virtual void increment(int step);
00255   virtual char Traversable () { return 1; }
00256 
00261   virtual char Testament () const;
00262   
00267   virtual char Book () const;
00268   
00273   virtual int Chapter () const;
00274   
00279   virtual int Verse () const;
00280   
00288   virtual char Testament (char itestament);
00289   
00297   virtual char Book (char ibook);
00298   
00306   virtual int Chapter (int ichapter);
00307   
00315   virtual int Verse (int iverse);
00316   
00323   virtual void Normalize (char autocheck = 0);
00324   
00333   virtual char AutoNormalize (char iautonorm = MAXPOS (char));
00334   
00343   virtual char Headings (char iheadings = MAXPOS (char));
00344   
00345   virtual long NewIndex () const;
00346   
00351   virtual long Index () const;
00352   
00358   virtual long Index (long iindex);
00359 
00360   virtual ListKey ParseVerseList (const char *buf, const char *defaultKey =
00361                                   "Genesis 1:1", bool expandRange = false);
00369   virtual int compare (const SWKey & ikey);
00370   
00378   virtual int _compare (const VerseKey & ikey);
00379   
00380   virtual void setBookAbbrevs (const struct abbrev *bookAbbrevs,
00381                                unsigned int size =
00382                                0 /* default determine size */ );
00383   virtual void setBooks (const char *iBMAX, struct sbook **ibooks);
00384   virtual void setLocale (const char *name);
00385 
00386   SWKEY_OPERATORS
00387 
00388   virtual SWKey & operator = (const VerseKey & ikey) { copyFrom(ikey); return *this; }
00389 };
00390 
00391 
00392 #endif

Generated at Fri Oct 5 22:45:34 2001 for The Sword Project by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001