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 #include <versificationmgr.h>
00030
00031 #include <defs.h>
00032
00033 SWORD_NAMESPACE_START
00034
00035 #define POS_MAXVERSE ((char)3)
00036 #define POS_MAXCHAPTER ((char)4)
00037 #define POS_MAXBOOK ((char)5)
00038
00039 #define MAXVERSE SW_POSITION(POS_MAXVERSE)
00040 #define MAXCHAPTER SW_POSITION(POS_MAXCHAPTER)
00041 #define MAXBOOK SW_POSITION(POS_MAXBOOK)
00042
00043
00044
00049 class SWDLLEXPORT VerseKey : public SWKey {
00050
00051 static SWClass classdef;
00052
00055 static int instance;
00056 ListKey internalListKey;
00057
00058 const VersificationMgr::System *refSys;
00059
00062 char autonorm;
00063
00066 char intros;
00067
00070 void init(const char *v11n = "KJV");
00071
00072
00073 void initBounds() const;
00074
00075
00076 void setFromOther(const VerseKey &vk);
00077
00078 void checkBounds();
00079
00080
00081 mutable long lowerBound, upperBound;
00082 mutable VerseKey *tmpClone;
00083
00084 typedef struct { int test; int book; int chap; int verse; char suffix; } VerseComponents;
00085
00086 mutable VerseComponents lowerBoundComponents, upperBoundComponents;
00087
00088 protected:
00089
00092 signed char testament;
00093 signed char book;
00094 signed int chapter;
00095 signed int verse;
00096 signed char suffix;
00097
00098
00099
00100
00101
00102
00103
00104
00105 virtual int getBookFromAbbrev(const char *abbr) const;
00106
00111 void freshtext() const;
00115 virtual char parse(bool checkNormalize = true);
00116 public:
00117 #if 0
00118 static long otbks[];
00119 static long otcps[];
00120 static long ntbks[];
00121 static long ntcps[];
00122 #endif
00123 int BMAX[2];
00124
00131 VerseKey(const char *ikey = 0);
00132
00139 VerseKey(const SWKey *ikey);
00140
00147 VerseKey(const char *min, const char *max, const char *v11n = "KJV");
00148
00154 VerseKey(const SWKey &k);
00155
00161 VerseKey(const VerseKey &k);
00162
00166 virtual ~VerseKey();
00167
00172 void setLowerBound(const VerseKey &lb);
00173 SWDEPRECATED VerseKey &LowerBound(const VerseKey &lb) { setLowerBound(lb); return getLowerBound(); }
00174
00179 void setUpperBound(const VerseKey &ub);
00180 SWDEPRECATED VerseKey &UpperBound(const VerseKey &ub) { setUpperBound(ub); return getUpperBound(); }
00181
00185 VerseKey &getLowerBound() const;
00186 SWDEPRECATED VerseKey &LowerBound() const { return getLowerBound(); }
00187
00191 VerseKey &getUpperBound() const;
00192 SWDEPRECATED VerseKey &UpperBound() const { return getUpperBound(); }
00193
00196 void clearBounds();
00197 SWDEPRECATED void ClearBounds() { clearBounds(); }
00198
00202 virtual SWKey *clone() const;
00203
00207 virtual const char *getText() const;
00208 virtual const char *getShortText() const;
00209 virtual void setText(const char *ikey, bool checkNormalize) { SWKey::setText(ikey); parse(checkNormalize); }
00210 virtual void setText(const char *ikey) { SWKey::setText(ikey); parse(); }
00211 virtual void copyFrom(const SWKey &ikey);
00212
00215 virtual void copyFrom(const VerseKey &ikey);
00216
00219 virtual void positionFrom(const SWKey &ikey);
00220
00226 virtual void setPosition(SW_POSITION newpos);
00227
00233 virtual void decrement(int steps = 1);
00234
00240 virtual void increment(int steps = 1);
00241 virtual bool isTraversable() const { return true; }
00242
00245 virtual const char *getBookName() const;
00246 virtual void setBookName(const char *bname);
00247
00248 virtual const char *getBookAbbrev() const;
00253 virtual char getTestament() const;
00257 SWDEPRECATED char Testament() const { return getTestament(); }
00258 virtual int getTestamentMax() const { return 2; }
00259
00264 virtual char getBook() const;
00268 SWDEPRECATED char Book() const { return getBook(); }
00269 virtual int getBookMax() const { return BMAX[testament-1]; }
00270
00275 virtual int getChapter() const;
00279 SWDEPRECATED int Chapter() const { return getChapter(); }
00280 virtual int getChapterMax() const;
00281
00286 virtual int getVerse() const;
00290 SWDEPRECATED int Verse() const { return getVerse(); }
00291 virtual int getVerseMax() const;
00292
00297 virtual char getSuffix() const;
00298
00303 virtual void setTestament(char itestament);
00307 SWDEPRECATED char Testament(char itestament) { char retVal = getTestament(); setTestament(itestament); return retVal; }
00308
00313 virtual void setBook(char ibook);
00317 SWDEPRECATED char Book(char ibook) { char retVal = getBook(); setBook(ibook); return retVal; }
00318
00323 virtual void setChapter(int ichapter);
00327 SWDEPRECATED int Chapter(int ichapter) { char retVal = getChapter(); setChapter(ichapter); return retVal; }
00328
00333 virtual void setVerse(int iverse);
00337 SWDEPRECATED int Verse(int iverse) { char retVal = getVerse(); setVerse(iverse); return retVal; }
00338
00343 virtual void setSuffix(char isuffix);
00344
00351 virtual void normalize(bool autocheck = false);
00352 SWDEPRECATED void Normalize(char autocheck = 0) { normalize(autocheck); }
00353
00362 virtual void setAutoNormalize(bool iautonorm);
00363 virtual bool isAutoNormalize() const;
00364
00368 SWDEPRECATED char AutoNormalize(char iautonorm) { char retVal = isAutoNormalize()?1:0; setAutoNormalize(iautonorm); return retVal; }
00372 SWDEPRECATED char AutoNormalize() const { return isAutoNormalize()?1:0; }
00373
00374
00384 SWDEPRECATED char Headings(char iheadings = MAXPOS(char)) { char retVal = isIntros(); if (iheadings != MAXPOS(char)) setIntros(iheadings); return retVal; }
00385
00389 virtual void setIntros(bool val);
00390 virtual bool isIntros() const;
00391
00392
00397 virtual long getIndex() const;
00398
00399
00405 virtual void setIndex(long iindex);
00406
00407
00412 virtual long getTestamentIndex() const;
00413
00417 SWDEPRECATED long TestamentIndex() const { return getTestamentIndex(); }
00418
00419 virtual const char *getOSISRef() const;
00420 virtual const char *getOSISBookName() const;
00421
00426 static const char *convertToOSIS(const char *inRef, const SWKey *defaultKey);
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 virtual ListKey parseVerseList(const char *buf, const char *defaultKey = 0, bool expandRange = false, bool useChapterAsVerse = false);
00444 SWDEPRECATED ListKey ParseVerseList(const char *buf, const char *defaultKey = 0, bool expandRange = false, bool useChapterAsVerse = false) { return parseVerseList(buf, defaultKey, expandRange, useChapterAsVerse); }
00445 virtual const char *getRangeText() const;
00446 virtual const char *getOSISRefRangeText() const;
00454 virtual int compare(const SWKey &ikey);
00455
00463 virtual int _compare(const VerseKey &ikey);
00464
00465 virtual void setVersificationSystem(const char *name);
00466 virtual const char *getVersificationSystem() const;
00467
00468
00469 void validateCurrentLocale() const;
00470
00471
00472
00473
00474
00475 SWKEY_OPERATORS
00476
00477 virtual SWKey &operator =(const VerseKey &ikey) { positionFrom(ikey); return *this; }
00478 };
00479
00480 SWORD_NAMESPACE_END
00481
00482 #endif //VERSEKEY_H