#include <versetreekey.h>


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 |
| virtual TreeKey * | getTreeKey () |
| 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) |
| virtual long | NewIndex () const |
| virtual void | normalize (bool autocheck=false) |
| virtual void | Normalize (char autocheck=0) |
| 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 | positionChanged () |
| 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 | setTreeKey (TreeKey *tk) |
| 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 |
| VerseTreeKey (const VerseTreeKey &k) | |
| VerseTreeKey (TreeKey *treeKey, const char *min, const char *max) | |
| VerseTreeKey (TreeKey *treeKey, const SWKey *ikey) | |
| VerseTreeKey (TreeKey *treeKey, const char *ikey=0) | |
| virtual | ~VerseTreeKey () |
Static Public Member Functions | |
| static const char * | convertToOSIS (const char *inRef, const SWKey *defaultKey) |
Public Attributes | |
| int | BMAX [2] |
| bool | internalPosChange |
| __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 | init (TreeKey *treeKey) |
| void | syncVerseToTree () |
Private Attributes | |
| long | lastGoodOffset |
| TreeKey * | treeKey |
Static Private Attributes | |
| static SWClass | classdef |
Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries.
Definition at line 39 of file versetreekey.h.
| VerseTreeKey::VerseTreeKey | ( | TreeKey * | treeKey, | |
| const char * | ikey = 0 | |||
| ) |
VerseKey Constructor - initializes Instance of VerseKey
| treeKey | a TreeKey which will form the basis of this VerseTreeKey | |
| ikey | text key (will take various forms of 'BOOK CH:VS'. See parse() for more detailed information) |
Definition at line 54 of file versetreekey.cpp.
VerseKey Constructor - initializes instance of VerseKey
| treeKey | a TreeKey which will form the basis of this VerseTreeKey | |
| ikey | base key (will take various forms of 'BOOK CH:VS'. See parse() for more detailed information) |
Definition at line 39 of file versetreekey.cpp.
| VerseTreeKey::VerseTreeKey | ( | TreeKey * | treeKey, | |
| const char * | min, | |||
| const char * | max | |||
| ) |
VerseKey Constructor - initializes instance of VerseKey with boundariess - see also LowerBound() and UpperBound()
| treeKey | a TreeKey which will form the basis of this VerseTreeKey | |
| min | the lower boundary of the new VerseKey | |
| max | the upper boundary of the new VerseKey |
Definition at line 68 of file versetreekey.cpp.
| VerseTreeKey::VerseTreeKey | ( | const VerseTreeKey & | k | ) |
| VerseTreeKey::~VerseTreeKey | ( | ) | [virtual] |
VerseKey Destructor Cleans up an instance of VerseKey
Definition at line 122 of file versetreekey.cpp.
00122 { 00123 delete treeKey; 00124 }
| int VerseKey::_compare | ( | const VerseKey & | ikey | ) | [virtual, inherited] |
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, inherited] |
Definition at line 372 of file versekey.h.
00372 { return isAutoNormalize()?1:0; } // deprecated
| SWDEPRECATED char VerseKey::AutoNormalize | ( | char | iautonorm | ) | [inline, inherited] |
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, inherited] |
Definition at line 317 of file versekey.h.
| SWDEPRECATED char VerseKey::Book | ( | ) | const [inline, inherited] |
Definition at line 268 of file versekey.h.
00268 { return getBook(); } // deprecated
| SWDEPRECATED int VerseKey::Chapter | ( | int | ichapter | ) | [inline, inherited] |
Definition at line 327 of file versekey.h.
00327 { char retVal = getChapter(); setChapter(ichapter); return retVal; } // deprecated
| SWDEPRECATED int VerseKey::Chapter | ( | ) | const [inline, inherited] |
Definition at line 279 of file versekey.h.
00279 { return getChapter(); } // deprecated
| virtual void SWKey::clearBound | ( | ) | const [inline, virtual, inherited] |
| SWDEPRECATED void VerseKey::ClearBounds | ( | ) | [inline, inherited] |
Definition at line 197 of file versekey.h.
00197 { clearBounds(); }
| void VerseKey::clearBounds | ( | ) | [inherited] |
| SWKey * VerseTreeKey::clone | ( | ) | const [virtual] |
Creates a new SWKey based on the current VerseKey see also the Copy Constructor
Reimplemented from VerseKey.
Definition at line 83 of file versetreekey.cpp.
00084 { 00085 return new VerseTreeKey(*this); 00086 }
| 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, inherited] |
| const char * VerseKey::convertToOSIS | ( | const char * | inRef, | |
| const SWKey * | defaultKey | |||
| ) | [static, inherited] |
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, inherited] |
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, inherited] |
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 VerseTreeKey::decrement | ( | int | steps = 1 |
) | [virtual] |
Decrements key a number of verses
| steps | Number of verses to jump backward |
Reimplemented from VerseKey.
Definition at line 127 of file versetreekey.cpp.
00127 { 00128 int treeError = 0; 00129 if (!error) lastGoodOffset = getTreeKey()->getOffset(); 00130 do { 00131 treeKey->decrement(); 00132 treeError = treeKey->popError(); 00133 // iterate until 3 levels and no versekey parse errors 00134 } while (!treeError && ((treeKey->getLevel() < 3) || error)); 00135 if (error && !treeError) { 00136 int saveError = error; 00137 increment(); 00138 error = saveError; 00139 } 00140 if (treeError) { 00141 treeKey->setOffset(lastGoodOffset); 00142 error = treeError; 00143 } 00144 if (_compare(getUpperBound()) > 0) { 00145 positionFrom(getUpperBound()); 00146 error = KEYERR_OUTOFBOUNDS; 00147 } 00148 if (_compare(getLowerBound()) < 0) { 00149 positionFrom(getLowerBound()); 00150 error = KEYERR_OUTOFBOUNDS; 00151 } 00152 }
| virtual bool SWKey::equals | ( | const SWKey & | ikey | ) | [inline, virtual, inherited] |
| SWDEPRECATED char SWKey::Error | ( | ) | [inline, inherited] |
| void VerseKey::freshtext | ( | ) | const [protected, inherited] |
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, inherited] |
Gets book
Definition at line 1407 of file versekey.cpp.
01408 { 01409 return book; 01410 }
| const char * VerseKey::getBookAbbrev | ( | ) | const [virtual, inherited] |
| int VerseTreeKey::getBookFromAbbrev | ( | const char * | abbr | ) | const [protected, virtual] |
Reimplemented from VerseKey.
Definition at line 89 of file versetreekey.cpp.
00090 { 00091 int bookno = VerseKey::getBookFromAbbrev(iabbr); 00092 if (bookno < 0) { 00093 /* 00094 vector<struct sbook>::iterator it = find(books, iabbr); 00095 if (it == books.end()) { 00096 TreeKey *tkey = this->treeKey; 00097 int saveError = tkey->popError(); 00098 long bookmark = tkey->getOffset(); 00099 SWBuf segment; 00100 internalPosChange = true; 00101 do { 00102 segment = (SWBuf)tkey->getLocalName(); 00103 } while (tkey->parent()); 00104 segment << 1; 00105 if (saveError) { 00106 error = saveError; 00107 } 00108 tkey->setOffset(bookmark); 00109 } 00110 books.push_back(sbook(iabbr)); 00111 */ 00112 } 00113 return bookno; 00114 }
| virtual int VerseKey::getBookMax | ( | ) | const [inline, virtual, inherited] |
Definition at line 269 of file versekey.h.
| const char * VerseKey::getBookName | ( | ) | const [virtual, inherited] |
Get/Set position of this key by Book Name
Definition at line 1174 of file versekey.cpp.
| int VerseKey::getChapter | ( | ) | const [virtual, inherited] |
Gets chapter
Definition at line 1419 of file versekey.cpp.
01420 { 01421 return chapter; 01422 }
| int VerseKey::getChapterMax | ( | ) | const [virtual, inherited] |
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, inherited] |
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 [inherited] |
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, inherited] |
| const char * VerseKey::getOSISRef | ( | ) | const [virtual, inherited] |
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, inherited] |
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, inherited] |
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, inherited] |
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, inherited] |
Gets verse suffix
Definition at line 1527 of file versekey.cpp.
01527 { 01528 return suffix; 01529 }
| char VerseKey::getTestament | ( | ) | const [virtual, inherited] |
Gets testament
Definition at line 1395 of file versekey.cpp.
01396 { 01397 return testament; 01398 }
| long VerseKey::getTestamentIndex | ( | ) | const [virtual, inherited] |
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, inherited] |
Definition at line 258 of file versekey.h.
| const char * VerseKey::getText | ( | ) | const [virtual, inherited] |
refreshes keytext before returning if cast to a (char *) is requested
Reimplemented from SWKey.
Definition at line 1151 of file versekey.cpp.
| TreeKey * VerseTreeKey::getTreeKey | ( | ) | [virtual] |
Reimplemented from TreeKey::PositionChangeListener.
Definition at line 250 of file versetreekey.cpp.
00250 { 00251 syncVerseToTree(); 00252 return treeKey; 00253 }
| VerseKey & VerseKey::getUpperBound | ( | ) | const [inherited] |
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, inherited] |
Gets verse
Definition at line 1431 of file versekey.cpp.
01432 { 01433 return verse; 01434 }
| int VerseKey::getVerseMax | ( | ) | const [virtual, inherited] |
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, inherited] |
Definition at line 272 of file versekey.cpp.
| SWDEPRECATED char VerseKey::Headings | ( | char | iheadings = MAXPOS(char) |
) | [inline, inherited] |
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 VerseTreeKey::increment | ( | int | steps = 1 |
) | [virtual] |
Increments key a number of verses
| steps | Number of verses to jump forward |
Reimplemented from VerseKey.
Definition at line 155 of file versetreekey.cpp.
00155 { 00156 int treeError = 0; 00157 if (!error) lastGoodOffset = getTreeKey()->getOffset(); 00158 do { 00159 treeKey->increment(); 00160 treeError = treeKey->popError(); 00161 // iterate until 3 levels and no versekey parse errors 00162 } while (!treeError && ((treeKey->getLevel() < 3) || error)); 00163 if (error && !treeError) { 00164 int saveError = error; 00165 decrement(); 00166 error = saveError; 00167 } 00168 if (treeError) { 00169 treeKey->setOffset(lastGoodOffset); 00170 error = treeError; 00171 } 00172 // bounds 00173 if (_compare(getUpperBound()) > 0) { 00174 positionFrom(getUpperBound()); 00175 error = KEYERR_OUTOFBOUNDS; 00176 } 00177 if (_compare(getLowerBound()) < 0) { 00178 positionFrom(getLowerBound()); 00179 error = KEYERR_OUTOFBOUNDS; 00180 } 00181 }
| void VerseTreeKey::init | ( | TreeKey * | treeKey | ) | [private] |
Definition at line 74 of file versetreekey.cpp.
00075 { 00076 myclass = &classdef; 00077 this->treeKey = (TreeKey *)treeKey->clone(); 00078 this->treeKey->setPositionChangeListener(this); 00079 internalPosChange = false; 00080 }
| bool VerseKey::isAutoNormalize | ( | ) | const [virtual, inherited] |
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, inherited] |
Definition at line 1566 of file versekey.cpp.
01567 { 01568 return intros; 01569 }
| bool SWKey::isPersist | ( | ) | const [inherited] |
| virtual bool VerseTreeKey::isTraversable | ( | ) | const [inline, virtual] |
Whether or not this key can be ++ -- incremented
Reimplemented from VerseKey.
Definition at line 99 of file versetreekey.h.
| SWDEPRECATED VerseKey& VerseKey::LowerBound | ( | ) | const [inline, inherited] |
Definition at line 186 of file versekey.h.
00186 { return getLowerBound(); }
Definition at line 173 of file versekey.h.
00173 { setLowerBound(lb); return getLowerBound(); }
| long VerseTreeKey::NewIndex | ( | ) | const [virtual] |
Definition at line 260 of file versetreekey.cpp.
| void VerseKey::normalize | ( | bool | autocheck = false |
) | [virtual, inherited] |
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 }
| void VerseTreeKey::Normalize | ( | char | autocheck = 0 |
) | [virtual] |
Reimplemented from VerseKey.
Definition at line 256 of file versetreekey.cpp.
00256 { 00257 error = 0; 00258 }
Definition at line 119 of file versetreekey.h.
00119 { copyFrom(ikey); return *this; }
| char VerseKey::parse | ( | bool | checkNormalize = true |
) | [protected, virtual, inherited] |
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, inherited] |
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, inherited] |
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] |
| void VerseTreeKey::positionChanged | ( | ) | [virtual] |
Implements TreeKey::PositionChangeListener.
Definition at line 184 of file versetreekey.cpp.
00184 { 00185 if (!internalPosChange) { 00186 TreeKey *tkey = this->TreeKey::PositionChangeListener::getTreeKey(); 00187 int saveError = tkey->popError(); 00188 long bookmark = tkey->getOffset(); 00189 SWBuf seg[4]; 00190 internalPosChange = true; 00191 int legs = 0; 00192 do { 00193 seg[legs] = tkey->getLocalName(); 00194 legs++; 00195 } while (tkey->parent() && (legs < 4)); 00196 00197 legs--; 00198 00199 if ((legs < 2) && (!seg[0].length() || seg[0] == "/")) { //"[ Module Heading ]"; 00200 testament = 0; 00201 book = 0; 00202 chapter = 0; 00203 setVerse(0); 00204 } 00205 else if ((legs < 2) 00206 && ((!strncmp(seg[0].c_str(), "[ Testament ", 12)) && //"[ Testament n Heading ]"; 00207 (isdigit(seg[0][12])) && 00208 (!strcmp(seg[0].c_str()+13, " Heading ]")))) { 00209 testament = (seg[0][12]-48); 00210 book = 0; 00211 chapter = 0; 00212 setVerse(0); 00213 } //path = "[ Module Heading ]"; 00214 else { 00215 setBookName(seg[--legs]); 00216 chapter = (legs > 0) ? atoi(seg[--legs]) : 0; 00217 setVerse((legs > 0) ? atoi(seg[--legs]) : 0); 00218 } 00219 00220 // setText(path); 00221 if (saveError) { 00222 error = saveError; 00223 } 00224 tkey->setOffset(bookmark); 00225 tkey->setError(saveError); 00226 internalPosChange = false; 00227 } 00228 }
| virtual void SWKey::positionFrom | ( | const SWKey & | ikey | ) | [inline, virtual, inherited] |
| void VerseKey::positionFrom | ( | const SWKey & | ikey | ) | [virtual, inherited] |
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, inherited] |
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, inherited] |
| void VerseKey::setBookName | ( | const char * | bname | ) | [virtual, inherited] |
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, inherited] |
| virtual void SWKey::setError | ( | char | err | ) | [inline, virtual, inherited] |
| void VerseKey::setIndex | ( | long | iindex | ) | [virtual, inherited] |
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, inherited] |
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 | ) | [inherited] |
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 VerseTreeKey::setPosition | ( | SW_POSITION | newpos | ) | [virtual] |
Positions this key
| newpos | Position to set to. |
Reimplemented from VerseKey.
Definition at line 265 of file versetreekey.cpp.
00265 { 00266 00267 if (isBoundSet()) { 00268 return VerseKey::setPosition(p); 00269 } 00270 00271 switch (p) { 00272 case POS_TOP: 00273 popError(); 00274 treeKey->setPosition(p); 00275 increment(); 00276 decrement(); 00277 popError(); 00278 break; 00279 case POS_BOTTOM: 00280 popError(); 00281 treeKey->setPosition(p); 00282 decrement(); 00283 increment(); 00284 popError(); 00285 break; 00286 case POS_MAXVERSE: 00287 case POS_MAXCHAPTER: 00288 VerseKey::setPosition(p); 00289 break; 00290 } 00291 }
| void VerseKey::setSuffix | ( | char | isuffix | ) | [virtual, inherited] |
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, inherited] |
| virtual void VerseKey::setText | ( | const char * | ikey | ) | [inline, virtual, inherited] |
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, inherited] |
Definition at line 209 of file versekey.h.
00209 { SWKey::setText(ikey); parse(checkNormalize); }
| void TreeKey::PositionChangeListener::setTreeKey | ( | TreeKey * | tk | ) | [inline, inherited] |
| void VerseKey::setUpperBound | ( | const VerseKey & | ub | ) | [inherited] |
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, inherited] |
Sets verse
| iverse | value which to set verse |
Definition at line 1519 of file versekey.cpp.
| void VerseKey::setVersificationSystem | ( | const char * | name | ) | [virtual, inherited] |
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 }
| void VerseTreeKey::syncVerseToTree | ( | ) | [private] |
Definition at line 231 of file versetreekey.cpp.
00231 { 00232 internalPosChange = true; 00233 SWBuf path; 00234 if (!getTestament()) path = "/"; // "[ Module Heading ]"; 00235 else if (!getBook()) path.setFormatted("/[ Testament %d Heading ]", getTestament()); 00236 else path.setFormatted("/%s/%d/%d", getOSISBookName(), getChapter(), getVerse()); 00237 if (getSuffix()) path += getSuffix(); 00238 long bookmark = treeKey->getOffset(); 00239 treeKey->setText(path); 00240 00241 // if our module has jacked inconsistencies, then let's put our tree back to where it was 00242 if (treeKey->popError()) { 00243 treeKey->setOffset(bookmark); 00244 } 00245 00246 internalPosChange = false; 00247 }
| SWDEPRECATED char VerseKey::Testament | ( | char | itestament | ) | [inline, inherited] |
Definition at line 307 of file versekey.h.
00307 { char retVal = getTestament(); setTestament(itestament); return retVal; } // deprecated
| SWDEPRECATED char VerseKey::Testament | ( | ) | const [inline, inherited] |
Definition at line 257 of file versekey.h.
00257 { return getTestament(); } // deprecated
| SWDEPRECATED long VerseKey::TestamentIndex | ( | ) | const [inline, inherited] |
Definition at line 417 of file versekey.h.
00417 { return getTestamentIndex(); } // deprecated, use getTestamentIndex()
| SWDEPRECATED VerseKey& VerseKey::UpperBound | ( | ) | const [inline, inherited] |
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 [inherited] |
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, inherited] |
Definition at line 337 of file versekey.h.
| SWDEPRECATED int VerseKey::Verse | ( | ) | const [inline, inherited] |
Definition at line 290 of file versekey.h.
00290 { return getVerse(); } // deprecated
int VerseKey::BMAX[2] [inherited] |
Definition at line 123 of file versekey.h.
signed char VerseKey::book [protected, inherited] |
Definition at line 93 of file versekey.h.
bool SWKey::boundSet [mutable, protected, inherited] |
signed int VerseKey::chapter [protected, inherited] |
Definition at line 94 of file versekey.h.
SWClass VerseTreeKey::classdef [static, private] |
Reimplemented from VerseKey.
Definition at line 41 of file versetreekey.h.
char SWKey::error [protected, inherited] |
Definition at line 105 of file versetreekey.h.
char* SWKey::keytext [protected, inherited] |
long VerseTreeKey::lastGoodOffset [private] |
Definition at line 47 of file versetreekey.h.
char* SWKey::localeName [protected, inherited] |
SWClass* SWObject::myclass [protected, inherited] |
Definition at line 53 of file swobject.h.
bool SWKey::persist [protected, inherited] |
char* SWKey::rangeText [mutable, protected, inherited] |
signed char VerseKey::suffix [protected, inherited] |
Definition at line 96 of file versekey.h.
signed char VerseKey::testament [protected, inherited] |
The Testament: 0 - Module Heading; 1 - Old; 2 - New
Definition at line 92 of file versekey.h.
TreeKey* VerseTreeKey::treeKey [private] |
Reimplemented from TreeKey::PositionChangeListener.
Definition at line 42 of file versetreekey.h.
__u64 SWKey::userData [inherited] |
signed int VerseKey::verse [protected, inherited] |
Definition at line 95 of file versekey.h.
1.6.1