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_8h-source.html,v 1.4 2002/01/22 14:20:28 jansorg 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 #include <ctype.h>
00030 
00031 #include <defs.h>
00032 
00033 #define POS_MAXVERSE ((char)3)
00034 #define POS_MAXCHAPTER ((char)4)
00035 #define POS_MAXBOOK ((char)5)
00036 
00037 #define MAXVERSE SW_POSITION(POS_MAXVERSE)
00038 #define MAXCHAPTER SW_POSITION(POS_MAXCHAPTER)
00039 #define MAXBOOK SW_POSITION(POS_MAXBOOK)
00040 
00041 struct sbook
00042 {
00045   const char *name;
00048   unsigned char chapmax;
00051   int *versemax;
00052 };
00053 
00054 struct abbrev
00055 {
00056   const char *ab;
00057   int book;
00058 };
00059 
00060 
00061 class SWLocale;
00062 
00067 class SWDLLEXPORT VerseKey:public SWKey
00068 {
00069   class LocaleCache
00070   {
00071   public:
00072     char *name;
00073     unsigned int abbrevsCnt;
00074     SWLocale *locale;
00075       LocaleCache ()
00076     {
00077       name = 0;
00078       abbrevsCnt = 0;
00079       locale = 0;
00080     }
00081      virtual ~LocaleCache ()
00082     {
00083       if (name)
00084         delete[]name;
00085     }
00086   };
00087 
00088   static SWClass classdef;
00089 
00090   static long *offsets[2][2];
00091   static int offsize[2][2];
00094   static int instance;
00095   static struct sbook otbooks[];
00096   static struct sbook ntbooks[];
00097   static long otbks[];
00098   static long otcps[];
00099   static long ntbks[];
00100   static long ntcps[];
00101   static int vm[];
00102   static LocaleCache localeCache;
00103   ListKey internalListKey;
00104 
00105   const struct abbrev *abbrevs;
00106   int abbrevsCnt;
00109   char testament;
00110   mutable char book;
00111   mutable int chapter;
00112   mutable int verse;
00115   char autonorm;
00118   char headings;
00119 
00120   int getBookAbbrev (const char *abbr);
00121   void initBounds () const;
00124   void initstatics ();
00127   void init ();
00132   void freshtext () const;
00136   virtual char parse ();
00145   int findindex (long *array, int size, long value);
00146   mutable VerseKey *lowerBound, *upperBound;
00147 
00148 public:
00149   static const char builtin_BMAX[2];
00150   static struct sbook *builtin_books[2];
00151   static const struct abbrev builtin_abbrevs[];
00152   const char *BMAX;
00153   struct sbook **books;
00154 
00161   VerseKey (const char *ikey = 0);
00162   
00169   VerseKey (const SWKey * ikey);
00170   
00177   VerseKey (const char *min, const char *max);
00178   
00184   VerseKey (VerseKey const &k);
00185   
00189   virtual ~ VerseKey ();
00190 
00197   VerseKey & LowerBound (const char *lb);
00198   
00204   VerseKey & UpperBound (const char *ub);
00205   
00209   VerseKey & LowerBound ()const;
00210   
00214   VerseKey & UpperBound ()const;
00215   
00218   void ClearBounds ();
00219   
00223   virtual SWKey *clone () const;
00224   
00228   virtual const char *getText() const;
00229   virtual void setText(const char *ikey) { SWKey::setText(ikey); parse (); }
00230   virtual void copyFrom(const SWKey & ikey);
00231   
00234   virtual void copyFrom(const VerseKey & ikey);
00235   
00241   virtual void setPosition(SW_POSITION);
00242   
00248   virtual void decrement(int step);
00249   
00255   virtual void increment(int step);
00256   virtual char Traversable () { return 1; }
00257 
00262   virtual char Testament () const;
00263   
00268   virtual char Book () const;
00269   
00274   virtual int Chapter () const;
00275   
00280   virtual int Verse () const;
00281   
00289   virtual char Testament (char itestament);
00290   
00298   virtual char Book (char ibook);
00299   
00307   virtual int Chapter (int ichapter);
00308   
00316   virtual int Verse (int iverse);
00317   
00324   virtual void Normalize (char autocheck = 0);
00325   
00334   virtual char AutoNormalize (char iautonorm = MAXPOS (char));
00335   
00344   virtual char Headings (char iheadings = MAXPOS (char));
00345   
00346   virtual long NewIndex () const;
00347   
00352   virtual long Index () const;
00353   
00359   virtual long Index (long iindex);
00360 
00361   virtual ListKey ParseVerseList (const char *buf, const char *defaultKey =
00362                                   "Genesis 1:1", bool expandRange = false);
00370   virtual int compare (const SWKey & ikey);
00371   
00379   virtual int _compare (const VerseKey & ikey);
00380   
00381   virtual void setBookAbbrevs (const struct abbrev *bookAbbrevs,
00382                                unsigned int size =
00383                                0 /* default determine size */ );
00384   virtual void setBooks (const char *iBMAX, struct sbook **ibooks);
00385   virtual void setLocale (const char *name);
00386 
00387   SWKEY_OPERATORS
00388 
00389   virtual SWKey & operator = (const VerseKey & ikey) { copyFrom(ikey); return *this; }
00390 };
00391 
00392 
00393 #endif

Generated at Tue Jan 22 14:52:49 2002 for The Sword Project by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001