#include <versekey.h>


Classes | |
| struct | VerseComponents |
Public Member Functions | |
| virtual int | _compare (const VerseKey &ikey) |
| SWDEPRECATED char | AutoNormalize () const |
| SWDEPRECATED char | AutoNormalize (char iautonorm) |
| SWDEPRECATED char | Book (char ibook) |
| SWDEPRECATED char | Book () const |
| SWDEPRECATED int | Chapter (int ichapter) |
| SWDEPRECATED int | Chapter () const |
| virtual void | clearBound () const |
| SWDEPRECATED void | ClearBounds () |
| void | clearBounds () |
| virtual SWKey * | clone () const |
| virtual int | compare (const SWKey &ikey) |
| virtual int | compare (const SWKey &ikey) |
| virtual void | copyFrom (const VerseKey &ikey) |
| virtual void | copyFrom (const SWKey &ikey) |
| virtual void | decrement (int steps=1) |
| virtual bool | equals (const SWKey &ikey) |
| SWDEPRECATED char | Error () |
| virtual char | getBook () const |
| virtual const char * | getBookAbbrev () const |
| virtual int | getBookMax () const |
| virtual const char * | getBookName () const |
| virtual int | getChapter () const |
| virtual int | getChapterMax () const |
| const SWClass * | getClass () const |
| virtual long | getIndex () const |
| char * | getLocale () const |
| VerseKey & | getLowerBound () const |
| virtual const char * | getOSISBookName () const |
| virtual const char * | getOSISRef () const |
| virtual const char * | getOSISRefRangeText () const |
| virtual const char * | getRangeText () const |
| virtual const char * | getShortText () const |
| virtual char | getSuffix () const |
| virtual char | getTestament () const |
| virtual long | getTestamentIndex () const |
| virtual int | getTestamentMax () const |
| virtual const char * | getText () const |
| VerseKey & | getUpperBound () const |
| virtual int | getVerse () const |
| virtual int | getVerseMax () const |
| virtual const char * | getVersificationSystem () const |
| SWDEPRECATED char | Headings (char iheadings=MAXPOS(char)) |
| virtual void | increment (int steps=1) |
| virtual bool | isAutoNormalize () const |
| virtual bool | isBoundSet () const |
| virtual bool | isIntros () const |
| bool | isPersist () const |
| virtual bool | isTraversable () const |
| SWDEPRECATED VerseKey & | LowerBound () const |
| SWDEPRECATED VerseKey & | LowerBound (const VerseKey &lb) |
| SWDEPRECATED void | Normalize (char autocheck=0) |
| virtual void | normalize (bool autocheck=false) |
| virtual SWKEY_OPERATORS SWKey & | operator= (const VerseKey &ikey) |
| SWDEPRECATED ListKey | ParseVerseList (const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false) |
| virtual ListKey | parseVerseList (const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false) |
| SWDEPRECATED char | Persist (signed char ipersist) |
| SWDEPRECATED char | Persist () const |
| virtual char | popError () |
| virtual void | positionFrom (const SWKey &ikey) |
| virtual void | positionFrom (const SWKey &ikey) |
| virtual void | setAutoNormalize (bool iautonorm) |
| virtual void | setBook (char ibook) |
| virtual void | setBookName (const char *bname) |
| virtual void | setChapter (int ichapter) |
| virtual void | setError (char err) |
| virtual void | setIndex (long iindex) |
| virtual void | setIntros (bool val) |
| void | setLocale (const char *name) |
| void | setLowerBound (const VerseKey &lb) |
| void | setPersist (bool ipersist) |
| virtual void | setPosition (SW_POSITION newpos) |
| virtual void | setSuffix (char isuffix) |
| virtual void | setTestament (char itestament) |
| virtual void | setText (const char *ikey) |
| virtual void | setText (const char *ikey, bool checkNormalize) |
| void | setUpperBound (const VerseKey &ub) |
| virtual void | setVerse (int iverse) |
| virtual void | setVersificationSystem (const char *name) |
| SWDEPRECATED char | Testament (char itestament) |
| SWDEPRECATED char | Testament () const |
| SWDEPRECATED long | TestamentIndex () const |
| SWDEPRECATED VerseKey & | UpperBound () const |
| SWDEPRECATED VerseKey & | UpperBound (const VerseKey &ub) |
| void | validateCurrentLocale () const |
| SWDEPRECATED int | Verse (int iverse) |
| SWDEPRECATED int | Verse () const |
| VerseKey (const VerseKey &k) | |
| VerseKey (const SWKey &k) | |
| VerseKey (const char *min, const char *max, const char *v11n="KJV") | |
| VerseKey (const SWKey *ikey) | |
| VerseKey (const char *ikey=0) | |
| virtual | ~VerseKey () |
Static Public Member Functions | |
| static const char * | convertToOSIS (const char *inRef, const SWKey *defaultKey) |
Public Attributes | |
| int | BMAX [2] |
| __u64 | userData |
Protected Member Functions | |
| void | freshtext () const |
| virtual int | getBookFromAbbrev (const char *abbr) const |
| SWLocale * | getPrivateLocale () const |
| virtual char | parse (bool checkNormalize=true) |
Protected Attributes | |
| signed char | book |
| bool | boundSet |
| signed int | chapter |
| char | error |
| char * | keytext |
| char * | localeName |
| SWClass * | myclass |
| bool | persist |
| char * | rangeText |
| signed char | suffix |
| signed char | testament |
| signed int | verse |
Private Member Functions | |
| void | checkBounds () |
| void | init (const char *v11n="KJV") |
| void | initBounds () const |
| void | setFromOther (const VerseKey &vk) |
Private Attributes | |
| char | autonorm |
| ListKey | internalListKey |
| char | intros |
| long | lowerBound |
| VerseComponents | lowerBoundComponents |
| const VersificationMgr::System * | refSys |
| VerseKey * | tmpClone |
| long | upperBound |
| VerseComponents | upperBoundComponents |
Static Private Attributes | |
| static SWClass | classdef |
| static int | instance = 0 |
Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries.
Definition at line 49 of file versekey.h.
| VerseKey::VerseKey | ( | const char * | ikey = 0 |
) |
VerseKey Constructor - initializes Instance of VerseKey
| ikey | text key (will take various forms of 'BOOK CH:VS'. See parse() for more detailed information) |
Definition at line 102 of file versekey.cpp.
| VerseKey::VerseKey | ( | const SWKey * | ikey | ) |
VerseKey Constructor - initializes instance of VerseKey
| ikey | base key (will take various forms of 'BOOK CH:VS'. See parse() for more detailed information) |
Definition at line 87 of file versekey.cpp.
| VerseKey::VerseKey | ( | const char * | min, | |
| const char * | max, | |||
| const char * | v11n = "KJV" | |||
| ) |
VerseKey Constructor - initializes instance of VerseKey with boundariess - see also LowerBound() and UpperBound()
Definition at line 217 of file versekey.cpp.
00217 : SWKey() 00218 { 00219 init(v11n); 00220 ListKey tmpListKey = parseVerseList(min); 00221 if (tmpListKey.Count()) { 00222 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0)); 00223 setLowerBound(*newElement); 00224 } 00225 tmpListKey = parseVerseList(max, min, true); 00226 if (tmpListKey.Count()) { 00227 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0)); 00228 setUpperBound((newElement->isBoundSet())?newElement->getUpperBound():*newElement); 00229 } 00230 setPosition(TOP); 00231 }
| VerseKey::VerseKey | ( | const SWKey & | k | ) |
| VerseKey::VerseKey | ( | const VerseKey & | k | ) |
| VerseKey::~VerseKey | ( | ) | [virtual] |
| int VerseKey::_compare | ( | const VerseKey & | ikey | ) | [virtual] |
Compares another VerseKey object
| ikey | key to compare with this one |
Definition at line 1687 of file versekey.cpp.
01688 { 01689 unsigned long keyval1 = 0; 01690 unsigned long keyval2 = 0; 01691 01692 keyval1 += getTestament() * 1000000000; 01693 keyval2 += ivkey.getTestament() * 1000000000; 01694 keyval1 += getBook() * 10000000; 01695 keyval2 += ivkey.getBook() * 10000000; 01696 keyval1 += getChapter() * 10000; 01697 keyval2 += ivkey.getChapter() * 10000; 01698 keyval1 += getVerse() * 50; 01699 keyval2 += ivkey.getVerse() * 50; 01700 keyval1 += (int)getSuffix(); 01701 keyval2 += (int)ivkey.getSuffix(); 01702 keyval1 = (keyval1 != keyval2) ? ((keyval1 > keyval2) ? 1 : -1) : 0; // -1 | 0 | 1 01703 return keyval1; 01704 }
| SWDEPRECATED char VerseKey::AutoNormalize | ( | ) | const [inline] |
Definition at line 372 of file versekey.h.
00372 { return isAutoNormalize()?1:0; } // deprecated
| SWDEPRECATED char VerseKey::AutoNormalize | ( | char | iautonorm | ) | [inline] |
Definition at line 368 of file versekey.h.
00368 { char retVal = isAutoNormalize()?1:0; setAutoNormalize(iautonorm); return retVal; } // deprecated
| SWDEPRECATED char VerseKey::Book | ( | char | ibook | ) | [inline] |
Definition at line 317 of file versekey.h.
| SWDEPRECATED char VerseKey::Book | ( | ) | const [inline] |
Definition at line 268 of file versekey.h.
00268 { return getBook(); } // deprecated
| SWDEPRECATED int VerseKey::Chapter | ( | int | ichapter | ) | [inline] |
Definition at line 327 of file versekey.h.
00327 { char retVal = getChapter(); setChapter(ichapter); return retVal; } // deprecated
| SWDEPRECATED int VerseKey::Chapter | ( | ) | const [inline] |
Definition at line 279 of file versekey.h.
00279 { return getChapter(); } // deprecated
| void VerseKey::checkBounds | ( | ) | [private] |
Definition at line 1638 of file versekey.cpp.
01638 { 01639 01640 long i = getIndex(); 01641 01642 initBounds(); 01643 if (i > upperBound) { 01644 setIndex(upperBound); 01645 i = getIndex(); 01646 error = KEYERR_OUTOFBOUNDS; 01647 } 01648 if (i < lowerBound) { 01649 setIndex(lowerBound); 01650 error = KEYERR_OUTOFBOUNDS; 01651 } 01652 }
| virtual void SWKey::clearBound | ( | ) | const [inline, virtual, inherited] |
| SWDEPRECATED void VerseKey::ClearBounds | ( | ) | [inline] |
Definition at line 197 of file versekey.h.
00197 { clearBounds(); }
| void VerseKey::clearBounds | ( | ) |
| SWKey * VerseKey::clone | ( | ) | const [virtual] |
Creates a new SWKey based on the current VerseKey see also the Copy Constructor
Reimplemented from SWKey.
Reimplemented in VerseTreeKey.
Definition at line 234 of file versekey.cpp.
00235 { 00236 return new VerseKey(*this); 00237 }
| int SWKey::compare | ( | const SWKey & | ikey | ) | [virtual, inherited] |
Compares this key object to another SWKey object
| ikey | key to compare with this one |
| int VerseKey::compare | ( | const SWKey & | ikey | ) | [virtual] |
| const char * VerseKey::convertToOSIS | ( | const char * | inRef, | |
| const SWKey * | defaultKey | |||
| ) | [static] |
Tries to parse a string and convert it into an OSIS reference
| inRef | reference string to try to parse | |
| defaultKey |
Definition at line 1759 of file versekey.cpp.
01759 { 01760 static SWBuf outRef; 01761 01762 outRef = ""; 01763 01764 VerseKey defLanguage; 01765 ListKey verses = defLanguage.parseVerseList(inRef, (*lastKnownKey), true); 01766 const char *startFrag = inRef; 01767 for (int i = 0; i < verses.Count(); i++) { 01768 SWKey *element = verses.GetElement(i); 01769 // VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i)); 01770 SWBuf buf; 01771 // TODO: This code really needs to not use fixed size arrays 01772 char frag[800]; 01773 char preJunk[800]; 01774 char postJunk[800]; 01775 memset(frag, 0, 800); 01776 memset(preJunk, 0, 800); 01777 memset(postJunk, 0, 800); 01778 while ((*startFrag) && (strchr(" {};,()[].", *startFrag))) { 01779 outRef += *startFrag; 01780 startFrag++; 01781 } 01782 memmove(frag, startFrag, ((const char *)element->userData - startFrag) + 1); 01783 frag[((const char *)element->userData - startFrag) + 1] = 0; 01784 int j; 01785 for (j = strlen(frag)-1; j && (strchr(" {};,()[].", frag[j])); j--); 01786 if (frag[j+1]) 01787 strcpy(postJunk, frag+j+1); 01788 frag[j+1]=0; 01789 startFrag += ((const char *)element->userData - startFrag) + 1; 01790 buf = "<reference osisRef=\""; 01791 buf += element->getOSISRefRangeText(); 01792 buf += "\">"; 01793 buf += frag; 01794 buf += "</reference>"; 01795 buf += postJunk; 01796 01797 outRef += buf; 01798 01799 } 01800 if (startFrag < (inRef + strlen(inRef))) 01801 outRef += startFrag; 01802 return outRef.c_str(); 01803 }
| void VerseKey::copyFrom | ( | const VerseKey & | ikey | ) | [virtual] |
Equates this VerseKey to another VerseKey
Reimplemented from SWKey.
Definition at line 176 of file versekey.cpp.
00176 { 00177 autonorm = ikey.autonorm; 00178 intros = ikey.intros; 00179 testament = ikey.getTestament(); 00180 book = ikey.getBook(); 00181 chapter = ikey.getChapter(); 00182 verse = ikey.getVerse(); 00183 suffix = ikey.getSuffix(); 00184 setLocale(ikey.getLocale()); 00185 setVersificationSystem(ikey.getVersificationSystem()); 00186 if (ikey.isBoundSet()) { 00187 setLowerBound(ikey.getLowerBound()); 00188 setUpperBound(ikey.getUpperBound()); 00189 } 00190 }
| void VerseKey::copyFrom | ( | const SWKey & | ikey | ) | [virtual] |
Definition at line 197 of file versekey.cpp.
00197 { 00198 // check to see if we can do a more specific copy 00199 // plus some optimizations 00200 const SWKey *fromKey = &ikey; 00201 ListKey *tryList = SWDYNAMIC_CAST(ListKey, fromKey); 00202 if (tryList) { 00203 SWKey *k = tryList->getElement(); 00204 if (k) fromKey = k; 00205 } 00206 VerseKey *tryVerse = SWDYNAMIC_CAST(VerseKey, fromKey); 00207 if (tryVerse) { 00208 copyFrom(*tryVerse); 00209 } 00210 else { 00211 SWKey::copyFrom(*fromKey); 00212 parse(); 00213 } 00214 }
| void VerseKey::decrement | ( | int | steps = 1 |
) | [virtual] |
Decrements key a number of verses
| steps | Number of verses to jump backward |
Reimplemented from SWKey.
Reimplemented in VerseTreeKey.
Definition at line 1281 of file versekey.cpp.
01281 { 01282 // if we're not autonormalizing and we're already not normalized 01283 if (!autonorm && chapter > 0 && verse > getVerseMax()) { 01284 verse -= step; 01285 checkBounds(); 01286 return; 01287 } 01288 char ierror = 0; 01289 setIndex(getIndex() - step); 01290 while ((!verse) && (!intros) && (!ierror)) { 01291 setIndex(getIndex() - 1); 01292 ierror = popError(); 01293 } 01294 if ((ierror) && (!intros)) 01295 (*this)++; 01296 01297 error = (ierror) ? ierror : error; 01298 }
| virtual bool SWKey::equals | ( | const SWKey & | ikey | ) | [inline, virtual, inherited] |
| SWDEPRECATED char SWKey::Error | ( | ) | [inline, inherited] |
| void VerseKey::freshtext | ( | ) | const [protected] |
Refresh keytext based on testament|book|chapter|verse default auto normalization to true default display headings option is false
Definition at line 313 of file versekey.cpp.
00314 { 00315 char buf[2024]; 00316 int realTest = testament; 00317 int realbook = book; 00318 00319 if (book < 1) { 00320 if (testament < 1) 00321 sprintf(buf, "[ Module Heading ]"); 00322 else sprintf(buf, "[ Testament %d Heading ]", (int)testament); 00323 } 00324 else { 00325 if (realbook > BMAX[realTest-1]) { 00326 realbook -= BMAX[realTest-1]; 00327 if (realTest < 2) 00328 realTest++; 00329 if (realbook > BMAX[realTest-1]) 00330 realbook = BMAX[realTest-1]; 00331 } 00332 sprintf(buf, "%s %d:%d", getBookName(), chapter, verse); 00333 if (suffix) { 00334 buf[strlen(buf)+1] = 0; 00335 buf[strlen(buf)] = suffix; 00336 } 00337 } 00338 00339 stdstr((char **)&keytext, buf); 00340 }
| char VerseKey::getBook | ( | ) | const [virtual] |
Gets book
Definition at line 1407 of file versekey.cpp.
01408 { 01409 return book; 01410 }
| const char * VerseKey::getBookAbbrev | ( | ) | const [virtual] |
| int VerseKey::getBookFromAbbrev | ( | const char * | abbr | ) | const [protected, virtual] |
Reimplemented in VerseTreeKey.
Definition at line 352 of file versekey.cpp.
00353 { 00354 int diff, abLen, min, max, target, retVal = -1; 00355 00356 char *abbr = 0; 00357 00358 int abbrevsCnt; 00359 00360 const struct abbrev *abbrevs = getPrivateLocale()->getBookAbbrevs(&abbrevsCnt); 00361 00362 StringMgr* stringMgr = StringMgr::getSystemStringMgr(); 00363 const bool hasUTF8Support = StringMgr::hasUTF8Support(); 00364 00365 // The first iteration of this loop tries to uppercase 00366 // the string. If we still fail to match, we try 00367 // matching the string without any toupper logic. 00368 // This is useful for, say, Chinese user input 00369 // on a system that doesn't properly support 00370 // a true Unicode-toupper function (!hasUTF8Support) 00371 for (int i = 0; i < 2; i++) { 00372 stdstr(&abbr, iabbr, 2); 00373 strstrip(abbr); 00374 00375 if (!i) { 00376 if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales 00377 stringMgr->upperUTF8(abbr, strlen(abbr)*2); 00378 } 00379 else { 00380 stringMgr->upperLatin1(abbr); 00381 } 00382 } 00383 00384 abLen = strlen(abbr); 00385 00386 if (abLen) { 00387 min = 0; 00388 max = abbrevsCnt; 00389 00390 // binary search for a match 00391 while(1) { 00392 target = min + ((max - min) / 2); 00393 diff = strncmp(abbr, abbrevs[target].ab, abLen); 00394 if ((!diff)||(target >= max)||(target <= min)) 00395 break; 00396 if (diff > 0) 00397 min = target; 00398 else max = target; 00399 } 00400 00401 // lets keep backing up till we find the 'first' valid match 00402 for (; target > 0; target--) { 00403 if (strncmp(abbr, abbrevs[target-1].ab, abLen)) 00404 break; 00405 } 00406 00407 if (!diff) { 00408 // lets keep moving forward till we find an abbrev in our refSys 00409 retVal = refSys->getBookNumberByOSISName(abbrevs[target].osis); 00410 while ((retVal < 0) && (target < max) && (!strncmp(abbr, abbrevs[target+1].ab, abLen))) { 00411 target++; 00412 retVal = refSys->getBookNumberByOSISName(abbrevs[target].osis); 00413 } 00414 } 00415 else retVal = -1; 00416 } 00417 if (retVal > 0) 00418 break; 00419 } 00420 delete [] abbr; 00421 return retVal; 00422 }
| virtual int VerseKey::getBookMax | ( | ) | const [inline, virtual] |
Definition at line 269 of file versekey.h.
| const char * VerseKey::getBookName | ( | ) | const [virtual] |
Get/Set position of this key by Book Name
Definition at line 1174 of file versekey.cpp.
| int VerseKey::getChapter | ( | ) | const [virtual] |
Gets chapter
Definition at line 1419 of file versekey.cpp.
01420 { 01421 return chapter; 01422 }
| int VerseKey::getChapterMax | ( | ) | const [virtual] |
Definition at line 1236 of file versekey.cpp.
01236 { 01237 const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1); 01238 return (b) ? b->getChapterMax() : -1; 01239 }
| const SWClass* SWObject::getClass | ( | ) | const [inline, inherited] |
Use this to get the class definition and inheritance order.
Definition at line 59 of file swobject.h.
00059 { 00060 return myclass; 00061 }
| long VerseKey::getIndex | ( | ) | const [virtual] |
Gets index based upon current verse
Reimplemented from SWKey.
Definition at line 1578 of file versekey.cpp.
01579 { 01580 long offset; 01581 01582 if (!testament) { // if we want module heading 01583 offset = 0; 01584 } 01585 else if (!book) { // we want testament heading 01586 offset = ((testament == 2) ? refSys->getNTStartOffset():0) + 1; 01587 } 01588 else { 01589 offset = refSys->getOffsetFromVerse((((testament>1)?BMAX[0]:0)+book-1), chapter, verse); 01590 } 01591 return offset; 01592 }
| char* SWKey::getLocale | ( | ) | const [inline, inherited] |
Definition at line 215 of file swkey.h.
00215 { return localeName; }
| VerseKey & VerseKey::getLowerBound | ( | ) | const |
gets the lower boundary of this VerseKey
Definition at line 1063 of file versekey.cpp.
01064 { 01065 initBounds(); 01066 if (!isAutoNormalize()) { 01067 tmpClone->testament = lowerBoundComponents.test; 01068 tmpClone->book = lowerBoundComponents.book; 01069 tmpClone->chapter = lowerBoundComponents.chap; 01070 tmpClone->setVerse (lowerBoundComponents.verse); 01071 tmpClone->setSuffix (lowerBoundComponents.suffix); 01072 } 01073 else { 01074 tmpClone->setIndex(lowerBound); 01075 tmpClone->setSuffix (lowerBoundComponents.suffix); 01076 } 01077 01078 return (*tmpClone); 01079 }
| const char * VerseKey::getOSISBookName | ( | ) | const [virtual] |
| const char * VerseKey::getOSISRef | ( | ) | const [virtual] |
Definition at line 1707 of file versekey.cpp.
01707 { 01708 static char buf[5][254]; 01709 static int loop = 0; 01710 01711 if (loop > 4) 01712 loop = 0; 01713 01714 if (getVerse()) 01715 sprintf(buf[loop], "%s.%d.%d", getOSISBookName(), getChapter(), getVerse()); 01716 else if (getChapter()) 01717 sprintf(buf[loop], "%s.%d", getOSISBookName(), getChapter()); 01718 else if (getBook()) 01719 sprintf(buf[loop], "%s", getOSISBookName()); 01720 else buf[loop][0] = 0; 01721 return buf[loop++]; 01722 }
| const char * VerseKey::getOSISRefRangeText | ( | ) | const [virtual] |
Reimplemented from SWKey.
Definition at line 1745 of file versekey.cpp.
01745 { 01746 if (isBoundSet() && (lowerBound != upperBound)) { 01747 SWBuf buf = getLowerBound().getOSISRef(); 01748 buf += "-"; 01749 buf += getUpperBound().getOSISRef(); 01750 stdstr(&rangeText, buf.c_str()); 01751 } 01752 else stdstr(&rangeText, getOSISRef()); 01753 return rangeText; 01754 }
| SWLocale * SWKey::getPrivateLocale | ( | ) | const [protected, inherited] |
Definition at line 110 of file swkey.cpp.
00110 { 00111 if (!locale) { 00112 if ((!localeCache.name) || (strcmp(localeCache.name, localeName))) { 00113 stdstr(&(localeCache.name), localeName); 00114 // this line is the entire bit of work we're trying to avoid with the cache 00115 // worth it? compare time examples/cmdline/search KJV "God love world" to 00116 // same with this method reduced to: 00117 // if (!local) local = ... (call below); return locale; 00118 localeCache.locale = LocaleMgr::getSystemLocaleMgr()->getLocale(localeName); 00119 } 00120 locale = localeCache.locale; 00121 } 00122 return locale; 00123 }
| const char * VerseKey::getRangeText | ( | ) | const [virtual] |
Reimplemented from SWKey.
Definition at line 1729 of file versekey.cpp.
01729 { 01730 if (isBoundSet() && lowerBound != upperBound) { 01731 SWBuf buf = (const char *)getLowerBound(); 01732 buf += "-"; 01733 buf += (const char *)getUpperBound(); 01734 stdstr(&rangeText, buf.c_str()); 01735 } 01736 else stdstr(&rangeText, getText()); 01737 return rangeText; 01738 }
| const char * VerseKey::getShortText | ( | ) | const [virtual] |
Reimplemented from SWKey.
Definition at line 1157 of file versekey.cpp.
01157 { 01158 static char *stext = 0; 01159 char buf[2047]; 01160 freshtext(); 01161 if (book < 1) { 01162 if (testament < 1) 01163 sprintf(buf, "[ Module Heading ]"); 01164 else sprintf(buf, "[ Testament %d Heading ]", (int)testament); 01165 } 01166 else { 01167 sprintf(buf, "%s %d:%d", getBookAbbrev(), chapter, verse); 01168 } 01169 stdstr(&stext, buf); 01170 return stext; 01171 }
| char VerseKey::getSuffix | ( | ) | const [virtual] |
Gets verse suffix
Definition at line 1527 of file versekey.cpp.
01527 { 01528 return suffix; 01529 }
| char VerseKey::getTestament | ( | ) | const [virtual] |
Gets testament
Definition at line 1395 of file versekey.cpp.
01396 { 01397 return testament; 01398 }
| long VerseKey::getTestamentIndex | ( | ) | const [virtual] |
Gets index into current testament based upon current verse
Definition at line 1601 of file versekey.cpp.
01602 { 01603 long offset = getIndex(); 01604 return (testament > 1) ? offset - refSys->getNTStartOffset() : offset; 01605 }
| virtual int VerseKey::getTestamentMax | ( | ) | const [inline, virtual] |
Definition at line 258 of file versekey.h.
| const char * VerseKey::getText | ( | ) | const [virtual] |
refreshes keytext before returning if cast to a (char *) is requested
Reimplemented from SWKey.
Definition at line 1151 of file versekey.cpp.
| VerseKey & VerseKey::getUpperBound | ( | ) | const |
gets the upper boundary of this VerseKey
Definition at line 1086 of file versekey.cpp.
01087 { 01088 initBounds(); 01089 if (!isAutoNormalize()) { 01090 tmpClone->testament = upperBoundComponents.test; 01091 tmpClone->book = upperBoundComponents.book; 01092 tmpClone->chapter = upperBoundComponents.chap; 01093 tmpClone->setVerse (upperBoundComponents.verse); 01094 tmpClone->setSuffix (upperBoundComponents.suffix); 01095 } 01096 else { 01097 tmpClone->setIndex(upperBound); 01098 tmpClone->setSuffix (upperBoundComponents.suffix); 01099 } 01100 01101 return (*tmpClone); 01102 }
| int VerseKey::getVerse | ( | ) | const [virtual] |
Gets verse
Definition at line 1431 of file versekey.cpp.
01432 { 01433 return verse; 01434 }
| int VerseKey::getVerseMax | ( | ) | const [virtual] |
Definition at line 1241 of file versekey.cpp.
01241 { 01242 const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1); 01243 return (b) ? b->getVerseMax(chapter) : -1; 01244 }
| const char * VerseKey::getVersificationSystem | ( | ) | const [virtual] |
Definition at line 272 of file versekey.cpp.
| SWDEPRECATED char VerseKey::Headings | ( | char | iheadings = MAXPOS(char) |
) | [inline] |
Sets/gets flag that tells VerseKey to include chapter/book/testament/module intros
| iheadings | value which to set intros [MAXPOS(char)] - only get |
Definition at line 384 of file versekey.h.
| void VerseKey::increment | ( | int | steps = 1 |
) | [virtual] |
Increments key a number of verses
| steps | Number of verses to jump forward |
Reimplemented from SWKey.
Reimplemented in VerseTreeKey.
Definition at line 1255 of file versekey.cpp.
01255 { 01256 // if we're not autonormalizing and we're already not normalized 01257 if (!autonorm && chapter > 0 && verse > getVerseMax()) { 01258 verse += step; 01259 checkBounds(); 01260 return; 01261 } 01262 char ierror = 0; 01263 setIndex(getIndex() + step); 01264 while ((!verse) && (!intros) && (!ierror)) { 01265 setIndex(getIndex() + 1); 01266 ierror = popError(); 01267 } 01268 01269 error = (ierror) ? ierror : error; 01270 }
| void VerseKey::init | ( | const char * | v11n = "KJV" |
) | [private] |
initializes this VerseKey()
Definition at line 53 of file versekey.cpp.
00053 { 00054 myclass = &classdef; 00055 00056 instance++; 00057 autonorm = 1; // default auto normalization to true 00058 intros = false; // default display intros option is false 00059 upperBound = 0; 00060 lowerBound = 0; 00061 boundSet = false; 00062 testament = 1; 00063 book = 1; 00064 chapter = 1; 00065 verse = 1; 00066 suffix = 0; 00067 tmpClone = 0; 00068 refSys = 0; 00069 00070 setVersificationSystem(v11n); 00071 }
| void VerseKey::initBounds | ( | ) | const [private] |
Definition at line 1117 of file versekey.cpp.
01118 { 01119 if (!tmpClone) { 01120 tmpClone = (VerseKey *)this->clone(); 01121 tmpClone->setAutoNormalize(false); 01122 tmpClone->setIntros(true); 01123 tmpClone->setTestament((BMAX[1])?2:1); 01124 tmpClone->setBook(BMAX[(BMAX[1])?1:0]); 01125 tmpClone->setChapter(tmpClone->getChapterMax()); 01126 tmpClone->setVerse(tmpClone->getVerseMax()); 01127 upperBound = tmpClone->getIndex(); 01128 upperBoundComponents.test = tmpClone->getTestament(); 01129 upperBoundComponents.book = tmpClone->getBook(); 01130 upperBoundComponents.chap = tmpClone->getChapter(); 01131 upperBoundComponents.verse = tmpClone->getVerse(); 01132 upperBoundComponents.suffix = tmpClone->getSuffix(); 01133 01134 lowerBound = 0; 01135 lowerBoundComponents.test = 0; 01136 lowerBoundComponents.book = 0; 01137 lowerBoundComponents.chap = 0; 01138 lowerBoundComponents.verse = 0; 01139 lowerBoundComponents.suffix = 0; 01140 01141 } 01142 else tmpClone->setLocale(getLocale()); 01143 }
| bool VerseKey::isAutoNormalize | ( | ) | const [virtual] |
Definition at line 1540 of file versekey.cpp.
01541 { 01542 return autonorm; 01543 }
| virtual bool SWKey::isBoundSet | ( | ) | const [inline, virtual, inherited] |
| bool VerseKey::isIntros | ( | ) | const [virtual] |
Definition at line 1566 of file versekey.cpp.
01567 { 01568 return intros; 01569 }
| bool SWKey::isPersist | ( | ) | const [inherited] |
| virtual bool VerseKey::isTraversable | ( | ) | const [inline, virtual] |
Whether or not this key can be ++ -- incremented
Reimplemented from SWKey.
Reimplemented in VerseTreeKey.
Definition at line 241 of file versekey.h.
| SWDEPRECATED VerseKey& VerseKey::LowerBound | ( | ) | const [inline] |
Definition at line 186 of file versekey.h.
00186 { return getLowerBound(); }
Definition at line 173 of file versekey.h.
00173 { setLowerBound(lb); return getLowerBound(); }
| SWDEPRECATED void VerseKey::Normalize | ( | char | autocheck = 0 |
) | [inline] |
Reimplemented in VerseTreeKey.
Definition at line 352 of file versekey.h.
00352 { normalize(autocheck); }
| void VerseKey::normalize | ( | bool | autocheck = false |
) | [virtual] |
checks limits and normalizes if necessary (e.g. Matthew 29:47 = Mark 2:2). If last verse is exceeded, key is set to last Book CH:VS
Definition at line 1308 of file versekey.cpp.
01309 { 01310 01311 if ((!autocheck || autonorm) // only normalize if we were explicitely called or if autonorm is turned on 01312 ) { 01313 error = 0; 01314 01315 while ((testament < 3) && (testament > 0)) { 01316 01317 01318 if (book > BMAX[testament-1]) { 01319 book -= (BMAX[testament-1] + (intros?1:0)); 01320 testament++; 01321 continue; 01322 } 01323 if (book < (intros?0:1)) { 01324 if (--testament > 0) { 01325 book += (BMAX[testament-1] + (intros?1:0)); 01326 } 01327 continue; 01328 } 01329 01330 01331 if (chapter > getChapterMax()) { 01332 chapter -= (getChapterMax() + (intros?1:0)); 01333 book++; 01334 continue; 01335 } 01336 if (chapter < (intros?0:1)) { 01337 --book; 01338 chapter += (getChapterMax() + (intros?1:0)); 01339 continue; 01340 } 01341 01342 01343 if (chapter > 0 && verse > getVerseMax()) { 01344 verse -= (getVerseMax() + (intros?1:0)); 01345 chapter++; 01346 continue; 01347 } 01348 if (verse < (intros?0:1)) { 01349 if (--chapter < (intros?0:1)) { 01350 --book; 01351 chapter += (getChapterMax() + (intros?1:0)); 01352 } 01353 verse += (getVerseMax() + (intros?1:0)); 01354 continue; 01355 } 01356 01357 break; // If we've made it this far (all failure checks continue) we're ok 01358 } 01359 01360 if (testament > (BMAX[1]?2:1)) { 01361 testament = BMAX[1]?2:1; 01362 book = BMAX[testament-1]; 01363 chapter = getChapterMax(); 01364 verse = getVerseMax(); 01365 error = KEYERR_OUTOFBOUNDS; 01366 } 01367 01368 if (testament < 1) { 01369 error = ((!intros) || (testament < 0) || (book < 0)) ? KEYERR_OUTOFBOUNDS : 0; 01370 testament = ((intros) ? 0 : 1); 01371 book = ((intros) ? 0 : 1); 01372 chapter = ((intros) ? 0 : 1); 01373 verse = ((intros) ? 0 : 1); 01374 } 01375 01376 // should we always perform bounds checks? Tried but seems to cause infinite recursion 01377 if (_compare(getUpperBound()) > 0) { 01378 positionFrom(getUpperBound()); 01379 error = KEYERR_OUTOFBOUNDS; 01380 } 01381 if (_compare(getLowerBound()) < 0) { 01382 positionFrom(getLowerBound()); 01383 error = KEYERR_OUTOFBOUNDS; 01384 } 01385 } 01386 }
Definition at line 477 of file versekey.h.
00477 { positionFrom(ikey); return *this; }
| char VerseKey::parse | ( | bool | checkNormalize = true |
) | [protected, virtual] |
Parse a character array into testament|book|chapter|verse
Definition at line 282 of file versekey.cpp.
00283 { 00284 testament = BMAX[1]?2:1; 00285 book = BMAX[BMAX[1]?1:0]; 00286 chapter = 1; 00287 verse = 1; 00288 00289 int error = 0; 00290 00291 if (keytext) { 00292 // pass our own copy of keytext as keytext memory may be freshed during parse 00293 ListKey tmpListKey = parseVerseList(SWBuf(keytext).c_str()); 00294 if (tmpListKey.Count()) { 00295 this->positionFrom(*tmpListKey.getElement(0)); 00296 error = this->error; 00297 } else error = 1; 00298 } 00299 if (checkAutoNormalize) { 00300 normalize(true); 00301 } 00302 freshtext(); 00303 00304 return (this->error) ? this->error : (this->error = error); 00305 }
| SWDEPRECATED ListKey VerseKey::ParseVerseList | ( | const char * | buf, | |
| const char * | defaultKey = 0, |
|||
| bool | expandRange = false, |
|||
| bool | useChapterAsVerse = false | |||
| ) | [inline] |
Definition at line 444 of file versekey.h.
00444 { return parseVerseList(buf, defaultKey, expandRange, useChapterAsVerse); }
| ListKey VerseKey::parseVerseList | ( | const char * | buf, | |
| const char * | defaultKey = 0, |
|||
| bool | expandRange = false, |
|||
| bool | useChapterAsVerse = false | |||
| ) | [virtual] |
Definition at line 471 of file versekey.cpp.
00471 { 00472 00473 // hold on to our own copy of params, as threads/recursion may change outside values 00474 const char *bufStart = buf; 00475 SWBuf iBuf = buf; 00476 buf = iBuf.c_str(); 00477 SWBuf iDefaultKey = defaultKey; 00478 if (defaultKey) defaultKey = iDefaultKey.c_str(); 00479 00480 char book[2048]; // TODO: bad, remove 00481 char number[2048]; // TODO: bad, remove 00482 *book = 0; 00483 *number = 0; 00484 int tobook = 0; 00485 int tonumber = 0; 00486 char suffix = 0; 00487 int chap = -1, verse = -1; 00488 int bookno = 0; 00489 int loop; 00490 char comma = 0; 00491 char dash = 0; 00492 const char *orig = buf; 00493 int q; 00494 ListKey tmpListKey; 00495 ListKey internalListKey; 00496 char lastPartial = 0; 00497 bool inTerm = true; 00498 int notAllDigits = 0; 00499 bool doubleF = false; 00500 00501 // assert we have a buffer 00502 if (!buf) return internalListKey; 00503 00504 VerseKey *curKey = (VerseKey *)this->clone(); 00505 VerseKey *lastKey = (VerseKey *)this->clone(); 00506 lastKey->clearBounds(); 00507 curKey->clearBounds(); 00508 00509 // some silly checks for corner cases 00510 if (!strcmp(buf, "[ Module Heading ]")) { 00511 curKey->setVerse(0); 00512 curKey->setChapter(0); 00513 curKey->setBook(0); 00514 curKey->setTestament(0); 00515 lastKey->setLowerBound(*curKey); 00516 lastKey->setUpperBound(*curKey); 00517 internalListKey << *lastKey; 00518 delete curKey; 00519 delete lastKey; 00520 return internalListKey; 00521 } 00522 if ((!strncmp(buf, "[ Testament ", 12)) && 00523 (isdigit(buf[12])) && 00524 (!strcmp(buf+13, " Heading ]"))) { 00525 curKey->setVerse(0); 00526 curKey->setChapter(0); 00527 curKey->setBook(0); 00528 curKey->setTestament(buf[12]-48); 00529 lastKey->setLowerBound(*curKey); 00530 lastKey->setUpperBound(*curKey); 00531 internalListKey << *lastKey; 00532 delete curKey; 00533 delete lastKey; 00534 return internalListKey; 00535 } 00536 00537 curKey->setAutoNormalize(isAutoNormalize()); 00538 lastKey->setAutoNormalize(false); 00539 if (defaultKey) *lastKey = defaultKey; 00540 00541 while (*buf) { 00542 switch (*buf) { 00543 case ':': 00544 if (buf[1] != ' ') { // for silly "Mat 1:1: this verse...." 00545 number[tonumber] = 0; 00546 tonumber = 0; 00547 if (*number) { 00548 if (chap >= 0) 00549 verse = atoi(number); 00550 else chap = atoi(number); 00551 } 00552 *number = 0; 00553 comma = 0; 00554 break; 00555 } 00556 // otherwise drop down to next case 00557 case ' ': 00558 inTerm = true; 00559 while (true) { 00560 if ((!*number) || (chap < 0)) 00561 break; 00562 for (q = 1; ((buf[q]) && (buf[q] != ' ')); q++); 00563 if (buf[q] == ':') 00564 break; 00565 inTerm = false; 00566 break; 00567 } 00568 if (inTerm) { 00569 book[tobook++] = ' '; 00570 break; 00571 } 00572 00573 case '-': 00574 if (chap == -1) { 00575 book[tobook] = *buf; 00576 book[tobook+1] = *(buf+1); 00577 book[tobook+2] = 0; 00578 int bookno = getBookFromAbbrev(book); 00579 if (bookno > -1) { 00580 tobook++; 00581 buf++; 00582 break; 00583 } 00584 } 00585 case ',': // on number new verse 00586 case ';': // on number new chapter 00587 number[tonumber] = 0; 00588 tonumber = 0; 00589 if (*number) { 00590 if (chap >= 0) 00591 verse = atoi(number); 00592 else chap = atoi(number); 00593 } 00594 *number = 0; 00595 book[tobook] = 0; 00596 tobook = 0; 00597 bookno = -1; 00598 if (*book) { 00599 loop = strlen(book) - 1; 00600 00601 for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; } 00602 00603 if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') { 00604 book[loop--] = 0; 00605 } 00606 for (; loop+1; loop--) { 00607 if ((isdigit(book[loop])) || (book[loop] == ' ')) { 00608 book[loop] = 0; 00609 continue; 00610 } 00611 else { 00612 if ((SW_toupper(book[loop])=='F')&&(loop)) { 00613 if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) { 00614 book[loop] = 0; 00615 continue; 00616 } 00617 } 00618 } 00619 break; 00620 } 00621 00622 for (loop = strlen(book) - 1; loop+1; loop--) { 00623 if (book[loop] == ' ') { 00624 // "PS C" is ok, but "II C" is not ok 00625 if (isroman(&book[loop+1]) && !isroman(book,loop)) { 00626 if (verse == -1) { 00627 verse = chap; 00628 chap = from_rom(&book[loop+1]); 00629 book[loop] = 0; 00630 } 00631 } 00632 break; 00633 } 00634 } 00635 00636 if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev 00637 if (verse == -1) { 00638 verse = chap; 00639 chap = lastKey->getChapter(); 00640 *book = 0; 00641 } 00642 } 00643 if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev 00644 strcpy(book, lastKey->getBookName()); 00645 } 00646 bookno = getBookFromAbbrev(book); 00647 if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) { 00648 suffix = 0; 00649 } 00650 } 00651 if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) { 00652 char partial = 0; 00653 curKey->setVerse(1); 00654 curKey->setChapter(1); 00655 curKey->setBook(1); 00656 00657 if (bookno < 0) { 00658 curKey->setTestament(lastKey->getTestament()); 00659 curKey->setBook(lastKey->getBook()); 00660 } 00661 else { 00662 int t = 1; 00663 if (bookno > BMAX[0]) { 00664 t++; 00665 bookno -= BMAX[0]; 00666 } 00667 curKey->setTestament(t); 00668 curKey->setBook(bookno); 00669 } 00670 00671 00672 if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) { 00673 // if (comma) { 00674 curKey->setChapter(lastKey->getChapter()); 00675 curKey->setVerse(chap); // chap because this is the first number captured 00676 if (suffix) { 00677 curKey->setSuffix(suffix); 00678 } 00679 } 00680 else { 00681 if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->getChapterMax() == 1) { 00682 verse = chap; 00683 chap = 1; 00684 } 00685 00686 00687 if (chap >= 0) { 00688 curKey->setChapter(chap); 00689 } 00690 else { 00691 partial++; 00692 curKey->setChapter(1); 00693 } 00694 if (verse >= 0) { 00695 curKey->setVerse(verse); 00696 if (suffix) { 00697 curKey->setSuffix(suffix); 00698 } 00699 } 00700 else { 00701 partial++; 00702 curKey->setVerse(1); 00703 } 00704 } 00705 00706 // check for '-' 00707 for (q = 0; ((buf[q]) && (buf[q] == ' ')); q++); 00708 if ((buf[q] == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper 00709 buf+=q; 00710 lastKey->setLowerBound(*curKey); 00711 lastKey->setPosition(TOP); 00712 tmpListKey << *lastKey; 00713 ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize()); 00714 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00715 } 00716 else { 00717 if (!dash) { // if last separator was not a dash just add 00718 if (expandRange && partial) { 00719 lastKey->setLowerBound(*curKey); 00720 if (partial > 1) 00721 curKey->setPosition(MAXCHAPTER); 00722 if (partial > 0) 00723 *curKey = MAXVERSE; 00724 lastKey->setUpperBound(*curKey); 00725 *lastKey = TOP; 00726 tmpListKey << *lastKey; 00727 ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize()); 00728 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00729 } 00730 else { 00731 bool f = false; 00732 if (curKey->getSuffix() == 'f') { 00733 curKey->setSuffix(0); 00734 f = true; 00735 } 00736 lastKey->setLowerBound(*curKey); 00737 if (f && doubleF) (*curKey) = MAXVERSE; 00738 else if (f) (*curKey)++; 00739 lastKey->setUpperBound(*curKey); 00740 *lastKey = TOP; 00741 tmpListKey << *lastKey; 00742 ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize()); 00743 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00744 } 00745 } 00746 else if (expandRange) { 00747 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement()); 00748 if (newElement) { 00749 if (partial > 1) 00750 *curKey = MAXCHAPTER; 00751 if (partial > 0) 00752 *curKey = MAXVERSE; 00753 newElement->setUpperBound(*curKey); 00754 *lastKey = *curKey; 00755 *newElement = TOP; 00756 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00757 } 00758 } 00759 } 00760 lastPartial = partial; 00761 } 00762 *book = 0; 00763 chap = -1; 00764 verse = -1; 00765 suffix = 0; 00766 if (*buf == ',') 00767 comma = 1; 00768 else comma = 0; 00769 if (*buf == '-') 00770 dash = 1; 00771 else dash = 0; 00772 break; 00773 case 10: // ignore these 00774 case 13: 00775 case '[': 00776 case ']': 00777 case '(': 00778 case ')': 00779 case '{': 00780 case '}': 00781 break; 00782 case '.': 00783 if (buf > orig) { // ignore (break) if preceeding char is not a digit 00784 for (notAllDigits = tobook; notAllDigits; notAllDigits--) { 00785 if ((!isdigit(book[notAllDigits-1])) && (!strchr(" .", book[notAllDigits-1]))) 00786 break; 00787 } 00788 if (!notAllDigits && !isdigit(buf[1])) 00789 break; 00790 } 00791 00792 number[tonumber] = 0; 00793 tonumber = 0; 00794 if (*number) { 00795 if (chap >= 0) 00796 verse = atoi(number); 00797 else chap = atoi(number); 00798 *number = 0; 00799 } 00800 break; 00801 00802 default: 00803 if (isdigit(*buf)) { 00804 number[tonumber++] = *buf; 00805 suffix = 0; 00806 doubleF = 0; 00807 } 00808 else { 00809 switch (*buf) { 00810 case ' ': // ignore these and don't reset number 00811 case 'F': 00812 break; 00813 default: 00814 // suffixes (and oddly 'f'-- ff.) 00815 if ((*buf >= 'a' && *buf <= 'z' && (chap >=0 || bookno > -1 || lastKey->isBoundSet())) 00816 || *buf == 'f') { 00817 // if suffix is already an 'f', then we need to mark if we're doubleF. 00818 doubleF = (*buf == 'f' && suffix == 'f'); 00819 if (suffix && !doubleF) { 00820 // we've already had a suffix one, so this is another letter, thus any number is not a number, e.g., '2jn'. We're on 'n' 00821 number[tonumber] = 0; 00822 tonumber = 0; 00823 } 00824 suffix = *buf; 00825 } 00826 else { 00827 number[tonumber] = 0; 00828 tonumber = 0; 00829 } 00830 break; 00831 } 00832 } 00833 if (chap == -1) 00834 book[tobook++] = *buf; 00835 } 00836 buf++; 00837 } 00838 number[tonumber] = 0; 00839 tonumber = 0; 00840 if (*number) { 00841 if (chap >= 0) 00842 verse = atoi(number); 00843 else chap = atoi(number); 00844 } 00845 *number = 0; 00846 book[tobook] = 0; 00847 tobook = 0; 00848 if (*book) { 00849 loop = strlen(book) - 1; 00850 00851 for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; } 00852 00853 if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') { 00854 book[loop--] = 0; 00855 } 00856 for (; loop+1; loop--) { 00857 if ((isdigit(book[loop])) || (book[loop] == ' ')) { 00858 book[loop] = 0; 00859 continue; 00860 } 00861 else { 00862 if ((SW_toupper(book[loop])=='F')&&(loop)) { 00863 if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) { 00864 book[loop] = 0; 00865 continue; 00866 } 00867 } 00868 } 00869 break; 00870 } 00871 00872 for (loop = strlen(book) - 1; loop+1; loop--) { 00873 if (book[loop] == ' ') { 00874 // "PS C" is ok, but "II C" is not ok 00875 if (isroman(&book[loop+1]) && !isroman(book,loop)) { 00876 if (verse == -1) { 00877 verse = chap; 00878 chap = from_rom(&book[loop+1]); 00879 book[loop] = 0; 00880 } 00881 } 00882 break; 00883 } 00884 } 00885 00886 if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev. 00887 if (verse == -1) { 00888 verse = chap; 00889 chap = lastKey->getChapter(); 00890 *book = 0; 00891 } 00892 } 00893 00894 if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev 00895 strcpy(book, lastKey->getBookName()); 00896 } 00897 bookno = getBookFromAbbrev(book); 00898 if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) { 00899 suffix = 0; 00900 } 00901 } 00902 if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) { 00903 char partial = 0; 00904 curKey->setVerse(1); 00905 curKey->setChapter(1); 00906 curKey->setBook(1); 00907 00908 if (bookno < 0) { 00909 curKey->setTestament(lastKey->getTestament()); 00910 curKey->setBook(lastKey->getBook()); 00911 } 00912 else { 00913 int t = 1; 00914 if (bookno > BMAX[0]) { 00915 t++; 00916 bookno -= BMAX[0]; 00917 } 00918 curKey->setTestament(t); 00919 curKey->setBook(bookno); 00920 } 00921 00922 if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) { 00923 curKey->setChapter(lastKey->getChapter()); 00924 curKey->setVerse(chap); // chap because this is the first number captured 00925 if (suffix) { 00926 curKey->setSuffix(suffix); 00927 } 00928 } 00929 else { 00930 if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->getChapterMax() == 1) { 00931 verse = chap; 00932 chap = 1; 00933 } 00934 00935 00936 if (chap >= 0) { 00937 curKey->setChapter(chap); 00938 } 00939 else { 00940 partial++; 00941 curKey->setChapter(1); 00942 } 00943 if (verse >= 0) { 00944 curKey->setVerse(verse); 00945 if (suffix) { 00946 curKey->setSuffix(suffix); 00947 } 00948 } 00949 else { 00950 partial++; 00951 curKey->setVerse(1); 00952 } 00953 } 00954 00955 if ((*buf == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper 00956 lastKey->setLowerBound(*curKey); 00957 *lastKey = TOP; 00958 tmpListKey << *lastKey; 00959 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00960 } 00961 else { 00962 if (!dash) { // if last separator was not a dash just add 00963 if (expandRange && partial) { 00964 lastKey->setLowerBound(*curKey); 00965 if (partial > 1) 00966 *curKey = MAXCHAPTER; 00967 if (partial > 0) 00968 *curKey = MAXVERSE; 00969 lastKey->setUpperBound(*curKey); 00970 *lastKey = TOP; 00971 tmpListKey << *lastKey; 00972 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00973 } 00974 else { 00975 bool f = false; 00976 if (curKey->getSuffix() == 'f') { 00977 curKey->setSuffix(0); 00978 f = true; 00979 } 00980 lastKey->setLowerBound(*curKey); 00981 if (f && doubleF) (*curKey) = MAXVERSE; 00982 else if (f) (*curKey)++; 00983 lastKey->setUpperBound(*curKey); 00984 *lastKey = TOP; 00985 tmpListKey << *lastKey; 00986 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00987 } 00988 } 00989 else if (expandRange) { 00990 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement()); 00991 if (newElement) { 00992 if (partial > 1) 00993 *curKey = MAXCHAPTER; 00994 if (partial > 0) 00995 *curKey = MAXVERSE; 00996 newElement->setUpperBound(*curKey); 00997 *newElement = TOP; 00998 tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str())); 00999 } 01000 } 01001 } 01002 } 01003 *book = 0; 01004 tmpListKey = TOP; 01005 internalListKey = tmpListKey; 01006 internalListKey = TOP; // Align internalListKey to first element before passing back; 01007 01008 delete curKey; 01009 delete lastKey; 01010 01011 return internalListKey; 01012 }
| SWDEPRECATED char SWKey::Persist | ( | signed char | ipersist | ) | [inline, inherited] |
Sets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.
| ipersist | value which to set persist; |
Definition at line 153 of file swkey.h.
00153 { setPersist(ipersist); return isPersist(); }
| SWDEPRECATED char SWKey::Persist | ( | ) | const [inline, inherited] |
| char SWKey::popError | ( | ) | [virtual, inherited] |
| virtual void SWKey::positionFrom | ( | const SWKey & | ikey | ) | [inline, virtual, inherited] |
| void VerseKey::positionFrom | ( | const SWKey & | ikey | ) | [virtual] |
Only repositions this VerseKey to another VerseKey
Definition at line 143 of file versekey.cpp.
00143 { 00144 error = 0; 00145 const SWKey *fromKey = &ikey; 00146 ListKey *tryList = SWDYNAMIC_CAST(ListKey, fromKey); 00147 if (tryList) { 00148 SWKey *k = tryList->getElement(); 00149 if (k) fromKey = k; 00150 } 00151 VerseKey *tryVerse = SWDYNAMIC_CAST(VerseKey, fromKey); 00152 if (tryVerse) { 00153 setFromOther(*tryVerse); 00154 } 00155 else { 00156 SWKey::positionFrom(*fromKey); 00157 parse(); 00158 } 00159 00160 // should we always perform bounds checks? Tried but seems to cause infinite recursion 00161 if (_compare(getUpperBound()) > 0) { 00162 setFromOther(getUpperBound()); 00163 error = KEYERR_OUTOFBOUNDS; 00164 } 00165 if (_compare(getLowerBound()) < 0) { 00166 setFromOther(getLowerBound()); 00167 error = KEYERR_OUTOFBOUNDS; 00168 } 00169 }
| void VerseKey::setAutoNormalize | ( | bool | iautonorm | ) | [virtual] |
Sets flag that tells VerseKey to automatically normalize itself when modified
| iautonorm | value which to set autonorm [MAXPOS(char)] - only get |
Definition at line 1545 of file versekey.cpp.
| void VerseKey::setBook | ( | char | ibook | ) | [virtual] |
| void VerseKey::setBookName | ( | const char * | bname | ) | [virtual] |
Definition at line 1479 of file versekey.cpp.
01480 { 01481 int bnum = getBookFromAbbrev(bname); 01482 if (bnum > -1) { 01483 if (bnum > BMAX[0]) { 01484 bnum -= BMAX[0]; 01485 testament = 2; 01486 } 01487 else testament = 1; 01488 setBook(bnum); 01489 } 01490 else error = KEYERR_OUTOFBOUNDS; 01491 }
| void VerseKey::setChapter | ( | int | ichapter | ) | [virtual] |
| virtual void SWKey::setError | ( | char | err | ) | [inline, virtual, inherited] |
| void VerseKey::setFromOther | ( | const VerseKey & | vk | ) | [private] |
Definition at line 121 of file versekey.cpp.
00121 { 00122 if (refSys == ikey.refSys) { 00123 testament = ikey.getTestament(); 00124 book = ikey.getBook(); 00125 chapter = ikey.getChapter(); 00126 verse = ikey.getVerse(); 00127 suffix = ikey.getSuffix(); 00128 } 00129 // TODO: versification mapping 00130 // Here is where we will do v11n system conversions in the future 00131 // when we have a conversion mechanism 00132 // Ben Morgan has started thinking about this 00133 // Konstantin Maslyuk <kalemas@mail.ru> has submitted a patch) 00134 // Asked Konstantin to try his patch out with his favorite 00135 // SWORD frontend and report back how it goes. Need to follow up 00136 else { 00137 // For now, this is the best we can do 00138 setText(ikey.getText()); 00139 } 00140 }
| void VerseKey::setIndex | ( | long | iindex | ) | [virtual] |
Sets index based upon current verse
| iindex | value to set index to |
Reimplemented from SWKey.
Definition at line 1615 of file versekey.cpp.
01616 { 01617 // assert we're sane 01618 if (iindex < 0) { 01619 error = KEYERR_OUTOFBOUNDS; 01620 return; 01621 } 01622 01623 int b; 01624 error = refSys->getVerseFromOffset(iindex, &b, &chapter, &verse); 01625 book = (unsigned char)b; 01626 testament = 1; 01627 if (book > BMAX[0]) { 01628 book -= BMAX[0]; 01629 testament = 2; 01630 } 01631 // special case for Module and Testament heading 01632 if (book < 0) { testament = 0; book = 0; } 01633 if (chapter < 0) { book = 0; chapter = 0; } 01634 01635 checkBounds(); 01636 }
| void VerseKey::setIntros | ( | bool | val | ) | [virtual] |
The Intros property determine whether or not to include chapter/book/testament/module intros
Definition at line 1560 of file versekey.cpp.
| void SWKey::setLocale | ( | const char * | name | ) | [inline, inherited] |
Definition at line 216 of file swkey.h.
00216 { stdstr(&localeName, name); locale = 0; } // this will force an on demand lookup of our locale
| void VerseKey::setLowerBound | ( | const VerseKey & | lb | ) |
sets the lower boundary for this VerseKey
| lb | the new lower boundary for this VerseKey |
Definition at line 1019 of file versekey.cpp.
01020 { 01021 initBounds(); 01022 01023 lowerBound = lb.getIndex(); 01024 lowerBoundComponents.test = lb.getTestament(); 01025 lowerBoundComponents.book = lb.getBook(); 01026 lowerBoundComponents.chap = lb.getChapter(); 01027 lowerBoundComponents.verse = lb.getVerse(); 01028 lowerBoundComponents.suffix = lb.getSuffix(); 01029 01030 // both this following check and UpperBound check force upperBound to 01031 // change allowing LowerBound then UpperBound logic to always flow 01032 // and set values without restrictions, as expected 01033 if (upperBound < lowerBound) upperBound = lowerBound; 01034 boundSet = true; 01035 }
| void SWKey::setPersist | ( | bool | ipersist | ) | [inherited] |
| void VerseKey::setPosition | ( | SW_POSITION | newpos | ) | [virtual] |
Positions this key
| newpos | Position to set to. |
Reimplemented from SWKey.
Reimplemented in VerseTreeKey.
Definition at line 1197 of file versekey.cpp.
01197 { 01198 switch (p) { 01199 case POS_TOP: { 01200 const VerseKey *lb = &getLowerBound(); 01201 testament = (lb->getTestament() || intros) ? lb->getTestament() : 1; 01202 book = (lb->getBook() || intros) ? lb->getBook() : 1; 01203 chapter = (lb->getChapter() || intros) ? lb->getChapter() : 1; 01204 verse = (lb->getVerse() || intros) ? lb->getVerse() : 1; 01205 suffix = lb->getSuffix(); 01206 break; 01207 } 01208 case POS_BOTTOM: { 01209 const VerseKey *ub = &getUpperBound(); 01210 testament = (ub->getTestament() || intros) ? ub->getTestament() : 1; 01211 book = (ub->getBook() || intros) ? ub->getBook() : 1; 01212 chapter = (ub->getChapter() || intros) ? ub->getChapter() : 1; 01213 verse = (ub->getVerse() || intros) ? ub->getVerse() : 1; 01214 suffix = ub->getSuffix(); 01215 break; 01216 } 01217 case POS_MAXVERSE: 01218 suffix = 0; 01219 verse = 1; 01220 normalize(); 01221 verse = getVerseMax(); 01222 suffix = 0; 01223 break; 01224 case POS_MAXCHAPTER: 01225 suffix = 0; 01226 verse = 1; 01227 chapter = 1; 01228 normalize(); 01229 chapter = getChapterMax(); 01230 break; 01231 } 01232 normalize(true); 01233 popError(); // clear error from normalize 01234 }
| void VerseKey::setSuffix | ( | char | isuffix | ) | [virtual] |
Sets/gets verse suffix
| isuffix | value which to set verse suffix |
Definition at line 1531 of file versekey.cpp.
01531 { 01532 suffix = suf; 01533 }
| void VerseKey::setTestament | ( | char | itestament | ) | [virtual] |
| virtual void VerseKey::setText | ( | const char * | ikey | ) | [inline, virtual] |
Sets this SWKey with a character string
| ikey | string used to set this key |
Reimplemented from SWKey.
Definition at line 210 of file versekey.h.
00210 { SWKey::setText(ikey); parse(); }
| virtual void VerseKey::setText | ( | const char * | ikey, | |
| bool | checkNormalize | |||
| ) | [inline, virtual] |
Definition at line 209 of file versekey.h.
00209 { SWKey::setText(ikey); parse(checkNormalize); }
| void VerseKey::setUpperBound | ( | const VerseKey & | ub | ) |
sets the upper boundary for this VerseKey
| ub | the new upper boundary for this VerseKey |
Definition at line 1042 of file versekey.cpp.
01043 { 01044 initBounds(); 01045 01046 upperBound = ub.getIndex(); 01047 upperBoundComponents.test = ub.getTestament(); 01048 upperBoundComponents.book = ub.getBook(); 01049 upperBoundComponents.chap = ub.getChapter(); 01050 upperBoundComponents.verse = ub.getVerse(); 01051 upperBoundComponents.suffix = ub.getSuffix(); 01052 01053 // see setLowerBound comment, above 01054 if (upperBound < lowerBound) upperBound = lowerBound; 01055 boundSet = true; 01056 }
| void VerseKey::setVerse | ( | int | iverse | ) | [virtual] |
Sets verse
| iverse | value which to set verse |
Definition at line 1519 of file versekey.cpp.
| void VerseKey::setVersificationSystem | ( | const char * | name | ) | [virtual] |
Definition at line 254 of file versekey.cpp.
00254 { 00255 const VersificationMgr::System *newRefSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem(name); 00256 // TODO: cheese, but what should we do if requested v11n system isn't found? 00257 if (!newRefSys) newRefSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem("KJV"); 00258 if (refSys != newRefSys) { 00259 refSys = newRefSys; 00260 BMAX[0] = refSys->getBMAX()[0]; 00261 BMAX[1] = refSys->getBMAX()[1]; 00262 00263 // TODO: adjust bounds for versificaion system ??? 00264 // TODO: when we have mapping done, rethink this 00265 //necessary as our bounds might not mean anything in the new v11n system 00266 clearBounds(); 00267 } 00268 00269 }
| SWDEPRECATED char VerseKey::Testament | ( | char | itestament | ) | [inline] |
Definition at line 307 of file versekey.h.
00307 { char retVal = getTestament(); setTestament(itestament); return retVal; } // deprecated
| SWDEPRECATED char VerseKey::Testament | ( | ) | const [inline] |
Definition at line 257 of file versekey.h.
00257 { return getTestament(); } // deprecated
| SWDEPRECATED long VerseKey::TestamentIndex | ( | ) | const [inline] |
Definition at line 417 of file versekey.h.
00417 { return getTestamentIndex(); } // deprecated, use getTestamentIndex()
| SWDEPRECATED VerseKey& VerseKey::UpperBound | ( | ) | const [inline] |
Definition at line 192 of file versekey.h.
00192 { return getUpperBound(); }
Definition at line 180 of file versekey.h.
00180 { setUpperBound(ub); return getUpperBound(); }
| void VerseKey::validateCurrentLocale | ( | ) | const |
Definition at line 429 of file versekey.cpp.
00429 { 00430 if (SWLog::getSystemLog()->getLogLevel() >= SWLog::LOG_DEBUG) { //make sure log is wanted, this loop stuff costs a lot of time 00431 for (int i = 0; i < refSys->getBookCount(); i++) { 00432 const int bn = getBookFromAbbrev(getPrivateLocale()->translate(refSys->getBook(i)->getLongName())); 00433 if (bn != i+1) { 00434 char *abbr = 0; 00435 stdstr(&abbr, getPrivateLocale()->translate(refSys->getBook(i)->getLongName()), 2); 00436 strstrip(abbr); 00437 SWLog::getSystemLog()->logDebug("VerseKey::Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d, should be %d. Required entry to add to locale:", abbr, bn, i); 00438 00439 StringMgr* stringMgr = StringMgr::getSystemStringMgr(); 00440 const bool hasUTF8Support = StringMgr::hasUTF8Support(); 00441 if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales 00442 stringMgr->upperUTF8(abbr, strlen(abbr)*2); 00443 } 00444 else { 00445 stringMgr->upperLatin1(abbr); 00446 } 00447 SWLog::getSystemLog()->logDebug("%s=%s\n", abbr, refSys->getBook(i)->getOSISName()); 00448 delete [] abbr; 00449 } 00450 } 00451 } 00452 }
| SWDEPRECATED int VerseKey::Verse | ( | int | iverse | ) | [inline] |
Definition at line 337 of file versekey.h.
| SWDEPRECATED int VerseKey::Verse | ( | ) | const [inline] |
Definition at line 290 of file versekey.h.
00290 { return getVerse(); } // deprecated
char VerseKey::autonorm [private] |
flag for auto normalization
Definition at line 62 of file versekey.h.
| int VerseKey::BMAX[2] |
Definition at line 123 of file versekey.h.
signed char VerseKey::book [protected] |
Definition at line 93 of file versekey.h.
bool SWKey::boundSet [mutable, protected, inherited] |
signed int VerseKey::chapter [protected] |
Definition at line 94 of file versekey.h.
SWClass VerseKey::classdef [static, private] |
char SWKey::error [protected, inherited] |
int VerseKey::instance = 0 [static, private] |
number of instantiated VerseKey objects or derivitives
Definition at line 55 of file versekey.h.
ListKey VerseKey::internalListKey [private] |
Definition at line 56 of file versekey.h.
char VerseKey::intros [private] |
flag for intros on/off
Definition at line 66 of file versekey.h.
char* SWKey::keytext [protected, inherited] |
char* SWKey::localeName [protected, inherited] |
long VerseKey::lowerBound [mutable, private] |
Definition at line 81 of file versekey.h.
VerseComponents VerseKey::lowerBoundComponents [mutable, private] |
Definition at line 86 of file versekey.h.
SWClass* SWObject::myclass [protected, inherited] |
Definition at line 53 of file swobject.h.
bool SWKey::persist [protected, inherited] |
char* SWKey::rangeText [mutable, protected, inherited] |
const VersificationMgr::System* VerseKey::refSys [private] |
Definition at line 58 of file versekey.h.
signed char VerseKey::suffix [protected] |
Definition at line 96 of file versekey.h.
signed char VerseKey::testament [protected] |
The Testament: 0 - Module Heading; 1 - Old; 2 - New
Definition at line 92 of file versekey.h.
VerseKey* VerseKey::tmpClone [mutable, private] |
Definition at line 82 of file versekey.h.
long VerseKey::upperBound [mutable, private] |
Definition at line 81 of file versekey.h.
VerseComponents VerseKey::upperBoundComponents [mutable, private] |
Definition at line 86 of file versekey.h.
__u64 SWKey::userData [inherited] |
signed int VerseKey::verse [protected] |
Definition at line 95 of file versekey.h.
1.6.1