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 const char * getOSISRef () const
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 1402 of file versekey.cpp.

References Book(), Chapter(), Testament(), and Verse().

Referenced by compare(), Index(), and Normalize().

01403 {
01404         long keyval1 = 0;
01405         long keyval2 = 0;
01406 
01407         keyval1 += Testament() * 1000000000;
01408         keyval2 += ivkey.Testament() * 1000000000;
01409         keyval1 += Book() * 1000000;
01410         keyval2 += ivkey.Book() * 1000000;
01411         keyval1 += Chapter() * 1000;
01412         keyval2 += ivkey.Chapter() * 1000;
01413         keyval1 += Verse();
01414         keyval2 += ivkey.Verse();
01415         keyval1 -= keyval2;
01416         keyval1 = (keyval1) ? ((keyval1 > 0) ? 1 : -1) /*keyval1/labs(keyval1)*/:0; // -1 | 0 | 1
01417         return keyval1;
01418 }

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 1203 of file versekey.cpp.

References autonorm, and Normalize().

01204 {
01205         char retval = autonorm;
01206 
01207         if (iautonorm != MAXPOS(char)) {
01208                 autonorm = iautonorm;
01209                 Normalize(1);
01210         }
01211         return retval;
01212 }

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 1137 of file versekey.cpp.

References Chapter(), and Normalize().

01138 {
01139         char retval = book;
01140 
01141         Chapter(1);
01142         book = ibook;
01143         Normalize(1);
01144 
01145         return retval;
01146 }

char VerseKey::Book   const [virtual]
 

Gets book.

Returns:
value of book

Definition at line 1075 of file versekey.cpp.

Referenced by _compare(), and setPosition().

01076 {
01077         return book;
01078 }

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 1159 of file versekey.cpp.

References Normalize(), and Verse().

01160 {
01161         int retval = chapter;
01162 
01163         Verse(1);
01164         chapter = ichapter;
01165         Normalize(1);
01166 
01167         return retval;
01168 }

int VerseKey::Chapter   const [virtual]
 

Gets chapter.

Returns:
value of chapter

Definition at line 1087 of file versekey.cpp.

Referenced by _compare(), Book(), and setPosition().

01088 {
01089         return chapter;
01090 }

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 1385 of file versekey.cpp.

References _compare().

01386 {
01387         VerseKey ivkey = (const char *)ikey;
01388         return _compare(ivkey);
01389 }

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 833 of file versekey.cpp.

References SWKey::copyFrom(), and parse().

00833                                          {
00834         SWKey::copyFrom(ikey);
00835 
00836         parse();
00837 }

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 941 of file versekey.cpp.

References SWKey::Error(), headings, and Index().

00941                                  {
00942         char ierror = 0;
00943 
00944         Index(Index() - step);
00945         while ((!verse) && (!headings) && (!ierror)) {
00946                 Index(Index() - 1);
00947                 ierror = Error();
00948         }
00949         if ((ierror) && (!headings))
00950                 (*this)++;
00951 
00952         error = (ierror) ? ierror : error;
00953 }

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 1249 of file versekey.cpp.

Referenced by Index().

01250 {
01251         int lbound, ubound, tval;
01252 
01253         lbound = 0;
01254         ubound = size - 1;
01255         while ((ubound - lbound) > 1) {
01256                 tval = lbound + (ubound-lbound)/2;
01257                 if (array[tval] <= value)
01258                         lbound = tval;
01259                 else ubound = tval;
01260         }
01261         return (array[ubound] <= value) ? ubound : lbound;
01262 }

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 1226 of file versekey.cpp.

References headings, and Normalize().

01227 {
01228         char retval = headings;
01229 
01230         if (iheadings != MAXPOS(char)) {
01231                 headings = iheadings;
01232                 Normalize(1);
01233         }
01234         return retval;
01235 }

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 921 of file versekey.cpp.

References SWKey::Error(), headings, and Index().

00921                                  {
00922         char ierror = 0;
00923         Index(Index() + step);
00924         while ((!verse) && (!headings) && (!ierror)) {
00925                 Index(Index() + 1);
00926                 ierror = Error();
00927         }
00928 
00929         error = (ierror) ? ierror : error;
00930 }

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 1316 of file versekey.cpp.

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

01317 {
01318         long  offset;
01319 
01320 // This is the dirty stuff --------------------------------------------
01321 
01322         if (!testament)
01323                 testament = 1;
01324 
01325         if (iindex < 1) {                               // if (-) or module heading
01326                 if (testament < 2) {
01327                         if (iindex < 0) {
01328                                 testament = 0;  // previously we changed 0 -> 1
01329                                 error     = KEYERR_OUTOFBOUNDS;
01330                         }
01331                         else testament = 0;             // we want module heading
01332                 }
01333                 else {
01334                         testament--;
01335                         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)
01336                 }
01337         }
01338 
01339 // --------------------------------------------------------------------
01340 
01341 
01342         if (testament) {
01343                 if ((!error) && (iindex)) {
01344                         offset  = findindex(offsets[testament-1][1], offsize[testament-1][1], iindex);
01345                         verse   = iindex - offsets[testament-1][1][offset];
01346                         book    = findindex(offsets[testament-1][0], offsize[testament-1][0], offset);
01347                         chapter = offset - offsets[testament-1][0][VerseKey::book];
01348                         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.
01349                         if (verse) {            // only check if -1 won't give negative
01350                                 if (verse > books[testament-1][book-1].versemax[chapter-1]) {
01351                                         if (testament > 1) {
01352                                                 verse = books[testament-1][book-1].versemax[chapter-1];
01353                                                 error = KEYERR_OUTOFBOUNDS;
01354                                         }
01355                                         else {
01356                                                 testament++;
01357                                                 Index(verse - books[testament-2][book-1].versemax[chapter-1]);
01358                                         }
01359                                 }
01360                         }
01361                 }
01362         }
01363         if (_compare(UpperBound()) > 0) {
01364                 *this = UpperBound();
01365                 error = KEYERR_OUTOFBOUNDS;
01366         }
01367         if (_compare(LowerBound()) < 0) {
01368                 *this = LowerBound();
01369                 error = KEYERR_OUTOFBOUNDS;
01370         }
01371         return Index();
01372 }

long VerseKey::Index   const [virtual]
 

Gets index based upon current verse.

Returns:
offset

Reimplemented from SWKey.

Definition at line 1271 of file versekey.cpp.

References testament.

Referenced by decrement(), increment(), and Index().

01272 {
01273         long  offset;
01274 
01275         if (!testament) { // if we want module heading
01276                 offset = 0;
01277                 verse  = 0;
01278         }
01279         else {
01280                 if (!book)
01281                         chapter = 0;
01282                 if (!chapter)
01283                         verse   = 0;
01284 
01285                 offset = offsets[testament-1][0][book];
01286                 offset = offsets[testament-1][1][(int)offset + chapter];
01287                 if (!(offset|verse)) // if we have a testament but nothing else.
01288                         offset = 1;
01289         }
01290         return (offset + verse);
01291 }

VerseKey & VerseKey::LowerBound   const
 

gets the lower boundary of this VerseKey.

Returns:
the lower boundary of this VerseKey

Definition at line 761 of file versekey.cpp.

Referenced by Index(), Normalize(), setPosition(), and VerseKey().

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

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 705 of file versekey.cpp.

References Normalize().

00706 {
00707         if (!lowerBound) 
00708                 initBounds();
00709 
00710         (*lowerBound) = lb;
00711         lowerBound->Normalize();
00712 
00713         return (*lowerBound);
00714 }

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 963 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().

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

void VerseKey::setPosition SW_POSITION    [virtual]
 

Positions this key.

Parameters:
p  position
Returns:
*this

Reimplemented from SWKey.

Definition at line 884 of file versekey.cpp.

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

Referenced by VerseKey().

00884                                         {
00885         switch (p) {
00886         case POS_TOP:
00887                 testament = LowerBound().Testament();
00888                 book      = LowerBound().Book();
00889                 chapter   = LowerBound().Chapter();
00890                 verse     = LowerBound().Verse();
00891                 break;
00892         case POS_BOTTOM:
00893                 testament = UpperBound().Testament();
00894                 book      = UpperBound().Book();
00895                 chapter   = UpperBound().Chapter();
00896                 verse     = UpperBound().Verse();
00897                 break;
00898         case POS_MAXVERSE:
00899                 Normalize();
00900                 verse     = books[testament-1][book-1].versemax[chapter-1];
00901                 break;
00902         case POS_MAXCHAPTER:
00903                 verse     = 1;
00904                 Normalize();
00905                 chapter   = books[testament-1][book-1].chapmax;
00906                 break;
00907         } 
00908         Normalize(1);
00909         Error();        // clear error from normalize
00910 }

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 1115 of file versekey.cpp.

References Normalize(), and testament.

01116 {
01117         char retval = testament;
01118 
01119         if (itestament != MAXPOS(char)) {
01120                 testament = itestament;
01121                 Normalize(1);
01122         }
01123         return retval;
01124 }

char VerseKey::Testament   const [virtual]
 

Gets testament.

Returns:
value of testament

Definition at line 1063 of file versekey.cpp.

References testament.

Referenced by _compare(), and setPosition().

01064 {
01065         return testament;
01066 }

VerseKey & VerseKey::UpperBound   const
 

gets the upper boundary of this VerseKey.

Returns:
the upper boundary of this VerseKey

Definition at line 774 of file versekey.cpp.

Referenced by Index(), Normalize(), setPosition(), and VerseKey().

00775 {
00776         if (!upperBound) 
00777                 initBounds();
00778 
00779         return (*upperBound);
00780 }

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 721 of file versekey.cpp.

References Normalize().

00722 {
00723         if (!upperBound) 
00724                 initBounds();
00725 
00726 // need to set upperbound parsing to resolve to max verse/chap if not specified
00727            (*upperBound) = ub;
00728         if (*upperBound < *lowerBound)
00729                 *upperBound = *lowerBound;
00730         upperBound->Normalize();
00731 
00732 // until we have a proper method to resolve max verse/chap use this kludge
00733         int len = strlen(ub);
00734         bool alpha = false;
00735         bool versespec = false;
00736         bool chapspec = false;
00737         for (int i = 0; i < len; i++) {
00738                 if (isalpha(ub[i]))
00739                         alpha = true;
00740                 if (ub[i] == ':')       // if we have a : we assume verse spec
00741                         versespec = true;
00742                 if ((isdigit(ub[i])) && (alpha))        // if digit after alpha assume chap spec
00743                         chapspec = true;
00744         }
00745         if (!chapspec)
00746                 *upperBound = MAXCHAPTER;
00747         if (!versespec)
00748                 *upperBound = MAXVERSE;
00749         
00750 
00751 // -- end kludge
00752 
00753         return (*upperBound);
00754 }

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 1181 of file versekey.cpp.

References Normalize().

01182 {
01183         int retval = verse;
01184 
01185         verse = iverse;
01186         Normalize(1);
01187 
01188         return retval;
01189 }

int VerseKey::Verse   const [virtual]
 

Gets verse.

Returns:
value of verse

Definition at line 1099 of file versekey.cpp.

Referenced by _compare(), Chapter(), and setPosition().

01100 {
01101         return verse;
01102 }


The documentation for this class was generated from the following files:
Generated on Thu Jun 20 22:13:05 2002 for The Sword Project by doxygen1.2.15