Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

VerseKey Class Reference

Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries. More...

#include <versekey.h>

Inheritance diagram for VerseKey:

Inheritance graph
[legend]
Collaboration diagram for VerseKey:

Collaboration graph
[legend]
List of all members.

Public Methods

 VerseKey (const char *ikey=0)
 VerseKey Constructor - initializes Instance of VerseKey. More...

 VerseKey (const SWKey *ikey)
 VerseKey Constructor - initializes instance of VerseKey. More...

 VerseKey (const char *min, const char *max)
 VerseKey Constructor - initializes instance of VerseKey with boundariess - see also LowerBound and UpperBound. More...

 VerseKey (const VerseKey &k)
 VerseKey Copy Constructor - will create a new VerseKey based on an existing one. More...

virtual ~VerseKey ()
 VerseKey Destructor Cleans up an instance of VerseKey.

VerseKey & LowerBound (const char *lb)
 sets the lower boundary for this VerseKey and returns the new boundary. More...

VerseKey & UpperBound (const char *ub)
 sets the upper boundary for this VerseKey and returns the new boundary. More...

VerseKey & LowerBound () const
 gets the lower boundary of this VerseKey. More...

VerseKey & UpperBound () const
 gets the upper boundary of this VerseKey. More...

void ClearBounds ()
 clears the boundaries of this VerseKey.

virtual SWKeyclone () const
 Creates a new SWKey based on the current VerseKey see also the Copy Constructor.

virtual const char * getText () const
 refreshes keytext before returning if cast to a (char *) is requested.

virtual const char * getShortText () const
virtual void setText (const char *ikey)
 Equates this SWKey to a character string. More...

virtual void copyFrom (const SWKey &ikey)
 Equates this SWKey to another SWKey object. More...

virtual void copyFrom (const VerseKey &ikey)
 Equates this VerseKey to another VerseKey.

virtual void setPosition (SW_POSITION)
 Positions this key. More...

virtual void decrement (int step)
 Decrements key a number of verses. More...

virtual void increment (int step)
 Increments key a number of verses. More...

virtual char Traversable ()
virtual const char * getBookName () const
virtual const char * getBookAbbrev () const
virtual char Testament () const
 Gets testament. More...

virtual char Book () const
 Gets book. More...

virtual int Chapter () const
 Gets chapter. More...

virtual int Verse () const
 Gets verse. More...

virtual char Testament (char itestament)
 Sets/gets testament. More...

virtual char Book (char ibook)
 Sets/gets book. More...

virtual int Chapter (int ichapter)
 Sets/gets chapter. More...

virtual int Verse (int iverse)
 Sets/gets verse. More...

virtual void Normalize (char autocheck=0)
 checks limits and normalizes if necessary (e.g. More...

virtual char AutoNormalize (char iautonorm=MAXPOS(char))
 Sets/gets flag that tells VerseKey to automatically normalize itself when modified. More...

virtual char Headings (char iheadings=MAXPOS(char))
 Sets/gets flag that tells VerseKey to include chapter/book/testament/module headings. More...

virtual long NewIndex () const
virtual long Index () const
 Gets index based upon current verse. More...

virtual long Index (long iindex)
 Sets index based upon current verse. More...

virtual ListKey ParseVerseList (const char *buf, const char *defaultKey="Genesis 1:1", bool expandRange=false)
virtual int compare (const SWKey &ikey)
 Compares another SWKey object. More...

virtual int _compare (const VerseKey &ikey)
 Compares another VerseKey object. More...

virtual void setBookAbbrevs (const struct abbrev *bookAbbrevs, unsigned int size=0)
virtual void setBooks (const char *iBMAX, struct sbook **ibooks)
virtual void setLocale (const char *name)
virtual const char * getLocale () const
virtual SWKEY_OPERATORS SWKeyoperator= (const VerseKey &ikey)

Public Attributes

const char * BMAX
sbook ** books

Static Public Attributes

const char builtin_BMAX [2] = {39, 27}
sbook * builtin_books [2] = {0,0}
const struct abbrev builtin_abbrevs []

Private Methods

int getBookAbbrev (const char *abbr)
void initBounds () const
void initstatics ()
 initialize and allocate books array.

void init ()
 initializes this VerseKey().

void freshtext () const
 Refresh keytext based on testament|book|chapter|verse default auto normalization to true default display headings option is false.

virtual char parse ()
 Parse a character array into testament|book|chapter|verse.

int findindex (long *array, int size, long value)
 Binary search to find the index closest, but less than the given value. More...


Private Attributes

ListKey internalListKey
const struct abbrev * abbrevs
char * locale
int abbrevsCnt
signed char testament
 The Testament: 0 - Old; 1 - New.

signed char book
signed int chapter
signed int verse
char autonorm
 flag for auto normalization.

char headings
 flag for headings on/off.

VerseKey * lowerBound
VerseKey * upperBound

Static Private Attributes

SWClass classdef
long * offsets [2][2] = {{VerseKey::otbks, VerseKey::otcps}, {VerseKey::ntbks, VerseKey::ntcps}}
int offsize [2][2]
int instance = 0
 number of instantiated VerseKey objects or derivitives.

sbook otbooks []
sbook ntbooks []
long otbks []
long otcps []
long ntbks []
long ntcps []
int vm []
LocaleCache localeCache

Detailed Description

Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries.

Definition at line 72 of file versekey.h.


Constructor & Destructor Documentation

VerseKey::VerseKey const char *    ikey = 0
 

VerseKey Constructor - initializes Instance of VerseKey.

Parameters:
ikey  text key (will take various forms of 'BOOK CH:VS'. See parse for more detailed information)

Definition at line 89 of file versekey.cpp.

References init, and parse.

Referenced by clone.

00089                                    : SWKey(ikey)
00090 {
00091         init();
00092         if (ikey)
00093                 parse();
00094 }

VerseKey::VerseKey const SWKey   ikey
 

VerseKey Constructor - initializes instance of VerseKey.

Parameters:
ikey  base key (will take various forms of 'BOOK CH:VS'. See parse for more detailed information)

Definition at line 74 of file versekey.cpp.

References init, and parse.

00074                                     : SWKey(*ikey)
00075 {
00076         init();
00077         if (ikey)
00078                 parse();
00079 }

VerseKey::VerseKey const char *    min,
const char *    max
 

VerseKey Constructor - initializes instance of VerseKey with boundariess - see also LowerBound and UpperBound.

Parameters:
min  the lower boundary of the new VerseKey
max  the upper boundary of the new VerseKey

Definition at line 111 of file versekey.cpp.

References init, LowerBound, setPosition, and UpperBound.

00111                                                    : SWKey()
00112 {
00113         init();
00114         LowerBound(min);
00115         UpperBound(max);
00116         setPosition(TOP);
00117 }

VerseKey::VerseKey const VerseKey &    k
 

VerseKey Copy Constructor - will create a new VerseKey based on an existing one.

Parameters:
k  the VerseKey to copy from


Member Function Documentation

int VerseKey::_compare const VerseKey &    ikey [virtual]
 

Compares another VerseKey object.

Parameters:
ikey  key to compare with this one
Returns:
>0 if this VerseKey is greater than compare VerseKey, <0 if this VerseKey is smaller than compare VerseKey, 0 if the keys are the same

Definition at line 1389 of file versekey.cpp.

References Book, Chapter, Testament, and Verse.

Referenced by compare, Index, and Normalize.

01390 {
01391         long keyval1 = 0;
01392         long keyval2 = 0;
01393 
01394         keyval1 += Testament() * 1000000000;
01395         keyval2 += ivkey.Testament() * 1000000000;
01396         keyval1 += Book() * 1000000;
01397         keyval2 += ivkey.Book() * 1000000;
01398         keyval1 += Chapter() * 1000;
01399         keyval2 += ivkey.Chapter() * 1000;
01400         keyval1 += Verse();
01401         keyval2 += ivkey.Verse();
01402         keyval1 -= keyval2;
01403         keyval1 = (keyval1) ? ((keyval1 > 0) ? 1 : -1) /*keyval1/labs(keyval1)*/:0; // -1 | 0 | 1
01404         return keyval1;
01405 }

char VerseKey::AutoNormalize char    iautonorm = MAXPOS(char) [virtual]
 

Sets/gets flag that tells VerseKey to automatically normalize itself when modified.

Parameters:
iautonorm  value which to set autonorm [MAXPOS(char)] - only get
Returns:
if unchanged -> value of autonorm, if changed -> previous value of autonorm

Definition at line 1190 of file versekey.cpp.

References autonorm, and Normalize.

01191 {
01192         char retval = autonorm;
01193 
01194         if (iautonorm != MAXPOS(char)) {
01195                 autonorm = iautonorm;
01196                 Normalize(1);
01197         }
01198         return retval;
01199 }

char VerseKey::Book char    ibook [virtual]
 

Sets/gets book.

Parameters:
ibook  value which to set book [MAXPOS(char)] - only get
Returns:
if unchanged -> value of book, if changed -> previous value of book

Definition at line 1124 of file versekey.cpp.

References Chapter, and Normalize.

01125 {
01126         char retval = book;
01127 
01128         Chapter(1);
01129         book = ibook;
01130         Normalize(1);
01131 
01132         return retval;
01133 }

char VerseKey::Book   const [virtual]
 

Gets book.

Returns:
value of book

Definition at line 1062 of file versekey.cpp.

Referenced by _compare, and setPosition.

01063 {
01064         return book;
01065 }

int VerseKey::Chapter int    ichapter [virtual]
 

Sets/gets chapter.

Parameters:
ichapter  value which to set chapter [MAXPOS(int)] - only get
Returns:
if unchanged -> value of chapter, if changed -> previous value of chapter

Definition at line 1146 of file versekey.cpp.

References Normalize, and Verse.

01147 {
01148         int retval = chapter;
01149 
01150         Verse(1);
01151         chapter = ichapter;
01152         Normalize(1);
01153 
01154         return retval;
01155 }

int VerseKey::Chapter   const [virtual]
 

Gets chapter.

Returns:
value of chapter

Definition at line 1074 of file versekey.cpp.

Referenced by _compare, Book, and setPosition.

01075 {
01076         return chapter;
01077 }

int VerseKey::compare const SWKey   ikey [virtual]
 

Compares another SWKey object.

Parameters:
ikey  key to compare with this one
Returns:
>0 if this VerseKey is greater than compare SWKey, <0 if this VerseKey is smaller than compare SWKey, 0 if the keys are the same

Reimplemented from SWKey.

Definition at line 1372 of file versekey.cpp.

References _compare.

01373 {
01374         VerseKey ivkey = (const char *)ikey;
01375         return _compare(ivkey);
01376 }

void VerseKey::copyFrom const SWKey   ikey [virtual]
 

Equates this SWKey to another SWKey object.

Parameters:
ikey  other swkey object

Reimplemented from SWKey.

Definition at line 820 of file versekey.cpp.

References SWKey::copyFrom, and parse.

00820                                          {
00821         SWKey::copyFrom(ikey);
00822 
00823         parse();
00824 }

void VerseKey::decrement int    step [virtual]
 

Decrements key a number of verses.

Parameters:
decrement  Number of verses to jump backward
Returns:
*this

Reimplemented from SWKey.

Definition at line 928 of file versekey.cpp.

References SWKey::Error, headings, and Index.

00928                                  {
00929         char ierror = 0;
00930 
00931         Index(Index() - step);
00932         while ((!verse) && (!headings) && (!ierror)) {
00933                 Index(Index() - 1);
00934                 ierror = Error();
00935         }
00936         if ((ierror) && (!headings))
00937                 (*this)++;
00938 
00939         error = (ierror) ? ierror : error;
00940 }

int VerseKey::findindex long *    array,
int    size,
long    value
[private]
 

Binary search to find the index closest, but less than the given value.

Parameters:
array  long * to array to search
size  number of elements in the array
value  value to find
Returns:
the index into the array that is less than but closest to value

Definition at line 1236 of file versekey.cpp.

Referenced by Index.

01237 {
01238         int lbound, ubound, tval;
01239 
01240         lbound = 0;
01241         ubound = size - 1;
01242         while ((ubound - lbound) > 1) {
01243                 tval = lbound + (ubound-lbound)/2;
01244                 if (array[tval] <= value)
01245                         lbound = tval;
01246                 else ubound = tval;
01247         }
01248         return (array[ubound] <= value) ? ubound : lbound;
01249 }

char VerseKey::Headings char    iheadings = MAXPOS(char) [virtual]
 

Sets/gets flag that tells VerseKey to include chapter/book/testament/module headings.

Parameters:
iheadings  value which to set headings [MAXPOS(char)] - only get
Returns:
if unchanged -> value of headings, if changed -> previous value of headings

Definition at line 1213 of file versekey.cpp.

References headings, and Normalize.

01214 {
01215         char retval = headings;
01216 
01217         if (iheadings != MAXPOS(char)) {
01218                 headings = iheadings;
01219                 Normalize(1);
01220         }
01221         return retval;
01222 }

void VerseKey::increment int    step [virtual]
 

Increments key a number of verses.

Parameters:
increment  Number of verses to jump forward
Returns:
*this

Reimplemented from SWKey.

Definition at line 908 of file versekey.cpp.

References SWKey::Error, headings, and Index.

00908                                  {
00909         char ierror = 0;
00910         Index(Index() + step);
00911         while ((!verse) && (!headings) && (!ierror)) {
00912                 Index(Index() + 1);
00913                 ierror = Error();
00914         }
00915 
00916         error = (ierror) ? ierror : error;
00917 }

long VerseKey::Index long    iindex [virtual]
 

Sets index based upon current verse.

Parameters:
iindex  value to set index to
Returns:
offset

Reimplemented from SWKey.

Definition at line 1303 of file versekey.cpp.

References _compare, findindex, Index, LowerBound, testament, and UpperBound.

01304 {
01305         long  offset;
01306 
01307 // This is the dirty stuff --------------------------------------------
01308 
01309         if (!testament)
01310                 testament = 1;
01311 
01312         if (iindex < 1) {                               // if (-) or module heading
01313                 if (testament < 2) {
01314                         if (iindex < 0) {
01315                                 testament = 0;  // previously we changed 0 -> 1
01316                                 error     = KEYERR_OUTOFBOUNDS;
01317                         }
01318                         else testament = 0;             // we want module heading
01319                 }
01320                 else {
01321                         testament--;
01322                         iindex = (offsets[testament-1][1][offsize[testament-1][1]-1] + books[testament-1][BMAX[testament-1]-1].versemax[books[testament-1][BMAX[testament-1]-1].chapmax-1]) + iindex; // What a doozy! ((offset of last chapter + number of verses in the last chapter) + iindex)
01323                 }
01324         }
01325 
01326 // --------------------------------------------------------------------
01327 
01328 
01329         if (testament) {
01330                 if ((!error) && (iindex)) {
01331                         offset  = findindex(offsets[testament-1][1], offsize[testament-1][1], iindex);
01332                         verse   = iindex - offsets[testament-1][1][offset];
01333                         book    = findindex(offsets[testament-1][0], offsize[testament-1][0], offset);
01334                         chapter = offset - offsets[testament-1][0][VerseKey::book];
01335                         verse   = (chapter) ? verse : 0;  // funny check. if we are index=1 (testmt header) all gets set to 0 exept verse.  Don't know why.  Fix if you figure out.  Think its in the offsets table.
01336                         if (verse) {            // only check if -1 won't give negative
01337                                 if (verse > books[testament-1][book-1].versemax[chapter-1]) {
01338                                         if (testament > 1) {
01339                                                 verse = books[testament-1][book-1].versemax[chapter-1];
01340                                                 error = KEYERR_OUTOFBOUNDS;
01341                                         }
01342                                         else {
01343                                                 testament++;
01344                                                 Index(verse - books[testament-2][book-1].versemax[chapter-1]);
01345                                         }
01346                                 }
01347                         }
01348                 }
01349         }
01350         if (_compare(UpperBound()) > 0) {
01351                 *this = UpperBound();
01352                 error = KEYERR_OUTOFBOUNDS;
01353         }
01354         if (_compare(LowerBound()) < 0) {
01355                 *this = LowerBound();
01356                 error = KEYERR_OUTOFBOUNDS;
01357         }
01358         return Index();
01359 }

long VerseKey::Index   const [virtual]
 

Gets index based upon current verse.

Returns:
offset

Reimplemented from SWKey.

Definition at line 1258 of file versekey.cpp.

References testament.

Referenced by decrement, increment, and Index.

01259 {
01260         long  offset;
01261 
01262         if (!testament) { // if we want module heading
01263                 offset = 0;
01264                 verse  = 0;
01265         }
01266         else {
01267                 if (!book)
01268                         chapter = 0;
01269                 if (!chapter)
01270                         verse   = 0;
01271 
01272                 offset = offsets[testament-1][0][book];
01273                 offset = offsets[testament-1][1][(int)offset + chapter];
01274                 if (!(offset|verse)) // if we have a testament but nothing else.
01275                         offset = 1;
01276         }
01277         return (offset + verse);
01278 }

VerseKey & VerseKey::LowerBound   const
 

gets the lower boundary of this VerseKey.

Returns:
the lower boundary of this VerseKey

Definition at line 748 of file versekey.cpp.

Referenced by Index, Normalize, setPosition, and VerseKey.

00749 {
00750         if (!lowerBound) 
00751                 initBounds();
00752 
00753         return (*lowerBound);
00754 }

VerseKey & VerseKey::LowerBound const char *    lb
 

sets the lower boundary for this VerseKey and returns the new boundary.

Parameters:
lb  the new lower boundary for this VerseKey
Returns:
the lower boundary the key was set to

Definition at line 692 of file versekey.cpp.

References Normalize.

00693 {
00694         if (!lowerBound) 
00695                 initBounds();
00696 
00697         (*lowerBound) = lb;
00698         lowerBound->Normalize();
00699 
00700         return (*lowerBound);
00701 }

void VerseKey::Normalize char    autocheck = 0 [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

Returns:
*this

Definition at line 950 of file versekey.cpp.

References _compare, autonorm, headings, LowerBound, testament, and UpperBound.

Referenced by AutoNormalize, Book, Chapter, Headings, LowerBound, parse, setPosition, Testament, UpperBound, and Verse.

00951 {
00952         error = 0;
00953 
00954         if ((autocheck) && (!autonorm)) // only normalize if we were explicitely called or if autonorm is turned on
00955                 return;
00956 
00957         if ((headings) && (!verse))             // this is cheeze and temporary until deciding what actions should be taken.
00958                 return;                                 // so headings should only be turned on when positioning with Index() or incrementors
00959 
00960         while ((testament < 3) && (testament > 0)) {
00961 
00962                 if (book > BMAX[testament-1]) {
00963                         book -= BMAX[testament-1];
00964                         testament++;
00965                         continue;
00966                 }
00967 
00968                 if (book < 1) {
00969                         if (--testament > 0) {
00970                                 book += BMAX[testament-1];
00971                         }
00972                         continue;
00973                 }
00974 
00975                 if (chapter > books[testament-1][book-1].chapmax) {
00976                         chapter -= books[testament-1][book-1].chapmax;
00977                         book++;
00978                         continue;
00979                 }
00980 
00981                 if (chapter < 1) {
00982                         if (--book > 0) {
00983                                 chapter += books[testament-1][book-1].chapmax;
00984                         }
00985                         else    {
00986                                 if (testament > 1) {
00987                                         chapter += books[0][BMAX[0]-1].chapmax;
00988                                 }
00989                         }
00990                         continue;
00991                 }
00992 
00993                 if (verse > books[testament-1][book-1].versemax[chapter-1]) { // -1 because e.g chapter 1 of Matthew is books[1][0].versemax[0]
00994                         verse -= books[testament-1][book-1].versemax[chapter++ - 1];
00995                         continue;
00996                 }
00997 
00998                 if (verse < 1) {
00999                         if (--chapter > 0) {
01000                                 verse += books[testament-1][book-1].versemax[chapter-1];
01001                         }
01002                         else    {
01003                                 if (book > 1) {
01004                                         verse += books[testament-1][book-2].versemax[books[testament-1][book-2].chapmax-1];
01005                                 }
01006                                 else    {
01007                                         if (testament > 1) {
01008                                                 verse += books[0][BMAX[0]-1].versemax[books[0][BMAX[0]-1].chapmax-1];
01009                                         }
01010                                 }
01011                         }
01012                         continue;
01013                 }
01014 
01015                 break;  // If we've made it this far (all failure checks continue) we're ok
01016         }
01017 
01018         if (testament > 2) {
01019                 testament = 2;
01020                 book      = BMAX[testament-1];
01021                 chapter   = books[testament-1][book-1].chapmax;
01022                 verse     = books[testament-1][book-1].versemax[chapter-1];
01023                 error     = KEYERR_OUTOFBOUNDS;
01024         }
01025 
01026         if (testament < 1) {
01027                 error     = ((!headings) || (testament < 0) || (book < 0)) ? KEYERR_OUTOFBOUNDS : 0;
01028                 testament = ((headings) ? 0 : 1);
01029                 book      = ((headings) ? 0 : 1);
01030                 chapter   = ((headings) ? 0 : 1);
01031                 verse     = ((headings) ? 0 : 1);
01032         }
01033         if (_compare(UpperBound()) > 0) {
01034                 *this = UpperBound();
01035                 error = KEYERR_OUTOFBOUNDS;
01036         }
01037         if (_compare(LowerBound()) < 0) {
01038                 *this = LowerBound();
01039                 error = KEYERR_OUTOFBOUNDS;
01040         }
01041 }

void VerseKey::setPosition SW_POSITION    [virtual]
 

Positions this key.

Parameters:
p  position
Returns:
*this

Reimplemented from SWKey.

Definition at line 871 of file versekey.cpp.

References Book, Chapter, SWKey::Error, LowerBound, Normalize, Testament, testament, UpperBound, and Verse.

Referenced by VerseKey.

00871                                         {
00872         switch (p) {
00873         case POS_TOP:
00874                 testament = LowerBound().Testament();
00875                 book      = LowerBound().Book();
00876                 chapter   = LowerBound().Chapter();
00877                 verse     = LowerBound().Verse();
00878                 break;
00879         case POS_BOTTOM:
00880                 testament = UpperBound().Testament();
00881                 book      = UpperBound().Book();
00882                 chapter   = UpperBound().Chapter();
00883                 verse     = UpperBound().Verse();
00884                 break;
00885         case POS_MAXVERSE:
00886                 Normalize();
00887                 verse     = books[testament-1][book-1].versemax[chapter-1];
00888                 break;
00889         case POS_MAXCHAPTER:
00890                 verse     = 1;
00891                 Normalize();
00892                 chapter   = books[testament-1][book-1].chapmax;
00893                 break;
00894         } 
00895         Normalize(1);
00896         Error();        // clear error from normalize
00897 }

virtual void VerseKey::setText const char *    ikey [inline, virtual]
 

Equates this SWKey to a character string.

Parameters:
ikey  string to set this key to

Reimplemented from SWKey.

Definition at line 236 of file versekey.h.

References SWKey::setText.

00236 { SWKey::setText(ikey); parse (); }

char VerseKey::Testament char    itestament [virtual]
 

Sets/gets testament.

Parameters:
itestament  value which to set testament [MAXPOS(char)] - only get
Returns:
if unchanged -> value of testament, if changed -> previous value of testament

Definition at line 1102 of file versekey.cpp.

References Normalize, and testament.

01103 {
01104         char retval = testament;
01105 
01106         if (itestament != MAXPOS(char)) {
01107                 testament = itestament;
01108                 Normalize(1);
01109         }
01110         return retval;
01111 }

char VerseKey::Testament   const [virtual]
 

Gets testament.

Returns:
value of testament

Definition at line 1050 of file versekey.cpp.

References testament.

Referenced by _compare, and setPosition.

01051 {
01052         return testament;
01053 }

VerseKey & VerseKey::UpperBound   const
 

gets the upper boundary of this VerseKey.

Returns:
the upper boundary of this VerseKey

Definition at line 761 of file versekey.cpp.

Referenced by Index, Normalize, setPosition, and VerseKey.

00762 {
00763         if (!upperBound) 
00764                 initBounds();
00765 
00766         return (*upperBound);
00767 }

VerseKey & VerseKey::UpperBound const char *    ub
 

sets the upper boundary for this VerseKey and returns the new boundary.

Parameters:
lb  the new upper boundary for this VerseKey
Returns:
the upper boundary the key was set to

Definition at line 708 of file versekey.cpp.

References Normalize.

00709 {
00710         if (!upperBound) 
00711                 initBounds();
00712 
00713 // need to set upperbound parsing to resolve to max verse/chap if not specified
00714            (*upperBound) = ub;
00715         if (*upperBound < *lowerBound)
00716                 *upperBound = *lowerBound;
00717         upperBound->Normalize();
00718 
00719 // until we have a proper method to resolve max verse/chap use this kludge
00720         int len = strlen(ub);
00721         bool alpha = false;
00722         bool versespec = false;
00723         bool chapspec = false;
00724         for (int i = 0; i < len; i++) {
00725                 if (isalpha(ub[i]))
00726                         alpha = true;
00727                 if (ub[i] == ':')       // if we have a : we assume verse spec
00728                         versespec = true;
00729                 if ((isdigit(ub[i])) && (alpha))        // if digit after alpha assume chap spec
00730                         chapspec = true;
00731         }
00732         if (!chapspec)
00733                 *upperBound = MAXCHAPTER;
00734         if (!versespec)
00735                 *upperBound = MAXVERSE;
00736         
00737 
00738 // -- end kludge
00739 
00740         return (*upperBound);
00741 }

int VerseKey::Verse int    iverse [virtual]
 

Sets/gets verse.

Parameters:
iverse  value which to set verse [MAXPOS(int)] - only get
Returns:
if unchanged -> value of verse, if changed -> previous value of verse

Definition at line 1168 of file versekey.cpp.

References Normalize.

01169 {
01170         int retval = verse;
01171 
01172         verse = iverse;
01173         Normalize(1);
01174 
01175         return retval;
01176 }

int VerseKey::Verse   const [virtual]
 

Gets verse.

Returns:
value of verse

Definition at line 1086 of file versekey.cpp.

Referenced by _compare, Chapter, and setPosition.

01087 {
01088         return verse;
01089 }


The documentation for this class was generated from the following files:
Generated on Wed Apr 3 22:34:19 2002 for The Sword Project by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002