00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 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 operator const char *() const;
00228 virtual SWKey & operator = (const char *ikey) { SWKey & retval =
00229 SWKey::operator = (ikey);
00230 parse ();
00231 return retval;
00232 }
00233
00236 virtual SWKey & operator = (const SWKey & ikey);
00237
00240 virtual SWKey & operator = (const VerseKey & ikey);
00241
00247 virtual SWKey & operator = (SW_POSITION);
00248
00254 virtual SWKey & operator -= (int decrement);
00255
00261 virtual SWKey & operator += (int increment);
00262 00263 00264 00265
00266 virtual char Traversable ()
00267 {
00268 return 1;
00269 }
00270
00275 virtual char Testament () const;
00276
00281 virtual char Book () const;
00282
00287 virtual int Chapter () const;
00288
00293 virtual int Verse () const;
00294
00302 virtual char Testament (char itestament);
00303
00311 virtual char Book (char ibook);
00312
00320 virtual int Chapter (int ichapter);
00321
00329 virtual int Verse (int iverse);
00330
00337 virtual void Normalize (char autocheck = 0);
00338
00347 virtual char AutoNormalize (char iautonorm = MAXPOS (char));
00348
00357 virtual char Headings (char iheadings = MAXPOS (char));
00358
00359 virtual long NewIndex () const;
00360
00365 virtual long Index () const;
00366
00372 virtual long Index (long iindex);
00373
00374 virtual ListKey ParseVerseList (const char *buf, const char *defaultKey =
00375 "Genesis 1:1", bool expandRange = false);
00383 virtual int compare (const SWKey & ikey);
00384
00392 virtual int _compare (const VerseKey & ikey);
00393
00394 virtual void setBookAbbrevs (const struct abbrev *bookAbbrevs,
00395 unsigned int size =
00396 0 );
00397 virtual void setBooks (const char *iBMAX, struct sbook **ibooks);
00398 virtual void setLocale (const char *name);
00399 };
00400
00401
00402 #endif