The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VerseKey Class Reference

#include <versekey.h>

+ Inheritance diagram for VerseKey:
+ Collaboration diagram for VerseKey:

Classes

struct  VerseComponents
 

Public Member Functions

virtual int _compare (const VerseKey &ikey)
 
SWDEPRECATED char AutoNormalize (char iautonorm)
 
SWDEPRECATED char AutoNormalize () const
 
SWDEPRECATED char Book () const
 
SWDEPRECATED char Book (char ibook)
 
SWDEPRECATED int Chapter () const
 
SWDEPRECATED int Chapter (int ichapter)
 
void clearBounds () const
 
SWDEPRECATED void ClearBounds ()
 
virtual SWKeyclone () const
 
virtual int compare (const SWKey &ikey)
 
virtual void copyFrom (const SWKey &ikey)
 
virtual void copyFrom (const VerseKey &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 SWClassgetClass () const
 
virtual char getError () const
 
virtual long getIndex () const
 
char * getLocale () const
 
VerseKeygetLowerBound () const
 
virtual const char * getOSISBookName () const
 
virtual const char * getOSISRef () const
 
virtual const char * getOSISRefRangeText () const
 
virtual const char * getRangeText () const
 
virtual const char * getShortRangeText () 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
 
VerseKeygetUpperBound () 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 VerseKeyLowerBound (const VerseKey &lb)
 
SWDEPRECATED VerseKeyLowerBound () const
 
virtual void normalize (bool autocheck=false)
 
SWDEPRECATED void Normalize (char autocheck=0)
 
virtual SWKEY_OPERATORS SWKeyoperator= (const VerseKey &ikey)
 
virtual ListKey parseVerseList (const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
 
SWDEPRECATED ListKey ParseVerseList (const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
 
SWDEPRECATED char Persist () const
 
SWDEPRECATED char Persist (signed char ipersist)
 
virtual char popError ()
 
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, bool checkNormalize)
 
virtual void setText (const char *ikey)
 
void setUpperBound (const VerseKey &ub)
 
virtual void setVerse (int iverse)
 
virtual void setVersificationSystem (const char *name)
 
SWDEPRECATED char Testament () const
 
SWDEPRECATED char Testament (char itestament)
 
SWDEPRECATED long TestamentIndex () const
 
SWDEPRECATED VerseKeyUpperBound (const VerseKey &ub)
 
SWDEPRECATED VerseKeyUpperBound () const
 
void validateCurrentLocale () const
 
SWDEPRECATED int Verse () const
 
SWDEPRECATED int Verse (int iverse)
 
 VerseKey (const char *ikey=0)
 
 VerseKey (const SWKey *ikey)
 
 VerseKey (const char *min, const char *max, const char *v11n="KJV")
 
 VerseKey (const SWKey &k)
 
 VerseKey (const VerseKey &k)
 
virtual ~VerseKey ()
 

Static Public Member Functions

static const char * convertToOSIS (const char *inRef, const SWKey *defaultKey)
 

Public Attributes

int BMAX [2]
 
SW_u64 userData
 

Protected Member Functions

void freshtext () const
 
virtual int getBookFromAbbrev (const char *abbr) const
 
SWLocalegetPrivateLocale () const
 
virtual char parse (bool checkNormalize=true)
 

Protected Attributes

signed char book
 
bool boundSet
 
signed int chapter
 
char error
 
char * keytext
 
char * localeName
 
const SWClassmyClass
 
bool persist
 
char * rangeText
 
signed char suffix
 
signed char testament
 
signed int verse
 

Private Member Functions

void checkBounds ()
 
void init (const char *v11n="KJV")
 
void initBounds () const
 
void setFromOther (const VerseKey &vk)
 

Private Attributes

char autonorm
 
ListKey internalListKey
 
char intros
 
long lowerBound
 
VerseComponents lowerBoundComponents
 
const VersificationMgr::SystemrefSys
 
VerseKeytmpClone
 
long upperBound
 
VerseComponents upperBoundComponents
 

Static Private Attributes

static int instance = 0
 

Detailed Description

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

Definition at line 53 of file versekey.h.

Constructor & Destructor Documentation

VerseKey::VerseKey ( const char *  ikey = 0)

VerseKey Constructor - initializes Instance of VerseKey

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

Definition at line 105 of file versekey.cpp.

105  : SWKey(ikeyText)
106 {
107  init();
108  if (ikeyText)
109  parse();
110 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
void init()
Definition: swkey.cpp:68
virtual char parse(bool checkNormalize=true)
Definition: versekey.cpp:326
VerseKey::VerseKey ( const SWKey ikey)

VerseKey Constructor - initializes instance of VerseKey

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

Definition at line 90 of file versekey.cpp.

90  : SWKey(*ikey)
91 {
92  init();
93  if (ikey)
94  copyFrom(*ikey);
95 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual void copyFrom(const SWKey &ikey)
Definition: versekey.cpp:239
void init()
Definition: swkey.cpp:68
VerseKey::VerseKey ( const char *  min,
const char *  max,
const char *  v11n = "KJV" 
)

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

Parameters
minthe lower boundary of the new VerseKey
maxthe upper boundary of the new VerseKey

Definition at line 261 of file versekey.cpp.

261  : SWKey()
262 {
263  init(v11n);
264  ListKey tmpListKey = parseVerseList(min);
265  if (tmpListKey.getCount()) {
266  VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
267  setLowerBound(*newElement);
268  }
269  tmpListKey = parseVerseList(max, min, true);
270  if (tmpListKey.getCount()) {
271  VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
272  setUpperBound((newElement->isBoundSet())?newElement->getUpperBound():*newElement);
273  }
274  setPosition(TOP);
275 }
virtual bool isBoundSet() const
Definition: swkey.h:189
#define TOP
Definition: swkey.h:68
virtual int getCount() const
Definition: listkey.cpp:211
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual void setPosition(SW_POSITION newpos)
Definition: versekey.cpp:1288
SWBuf v11n
Definition: osis2mod.cpp:107
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
void init()
Definition: swkey.cpp:68
virtual ListKey parseVerseList(const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
Definition: versekey.cpp:515
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
VerseKey::VerseKey ( const SWKey k)
VerseKey Copy Constructor - will create a new VerseKey

based on an existing SWKey

Parameters
kthe VerseKey to copy from

Definition at line 83 of file versekey.cpp.

83  : SWKey(ikey)
84 {
85  init();
86  copyFrom(ikey);
87 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual void copyFrom(const SWKey &ikey)
Definition: versekey.cpp:239
void init()
Definition: swkey.cpp:68
VerseKey::VerseKey ( const VerseKey k)
VerseKey Copy Constructor - will create a new VerseKey

based on an existing one

Parameters
kthe VerseKey to copy from

Definition at line 113 of file versekey.cpp.

113  : SWKey(k)
114 {
115  init();
116  copyFrom(k);
117 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual void copyFrom(const SWKey &ikey)
Definition: versekey.cpp:239
void init()
Definition: swkey.cpp:68
VerseKey::~VerseKey ( )
virtual
VerseKey Destructor

Cleans up an instance of VerseKey

Definition at line 290 of file versekey.cpp.

290  {
291 
292  delete tmpClone;
293 
294  --instance;
295 }
static int instance
Definition: versekey.h:58
VerseKey * tmpClone
Definition: versekey.h:85

Member Function Documentation

int VerseKey::_compare ( const VerseKey ikey)
virtual

Compares another VerseKey object

Parameters
ikeykey 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 1790 of file versekey.cpp.

1791 {
1792  unsigned long keyval1 = 0;
1793  unsigned long keyval2 = 0;
1794 
1795  keyval1 += getTestament() * 1000000000;
1796  keyval2 += ivkey.getTestament() * 1000000000;
1797  keyval1 += getBook() * 10000000;
1798  keyval2 += ivkey.getBook() * 10000000;
1799  keyval1 += getChapter() * 10000;
1800  keyval2 += ivkey.getChapter() * 10000;
1801  keyval1 += getVerse() * 50;
1802  keyval2 += ivkey.getVerse() * 50;
1803  keyval1 += (int)getSuffix();
1804  keyval2 += (int)ivkey.getSuffix();
1805  keyval1 = (keyval1 != keyval2) ? ((keyval1 > keyval2) ? 1 : -1) : 0; // -1 | 0 | 1
1806  return (int)keyval1;
1807 }
virtual char getSuffix() const
Definition: versekey.cpp:1630
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
virtual char getTestament() const
Definition: versekey.cpp:1498
SWDEPRECATED char VerseKey::AutoNormalize ( char  iautonorm)
inline
Deprecated:
Use setAutoNormalize() instead.

Definition at line 375 of file versekey.h.

375 { char retVal = isAutoNormalize()?1:0; setAutoNormalize(iautonorm!=0); return retVal; } // deprecated
virtual bool isAutoNormalize() const
Definition: versekey.cpp:1643
virtual void setAutoNormalize(bool iautonorm)
Definition: versekey.cpp:1648
SWDEPRECATED char VerseKey::AutoNormalize ( ) const
inline
Deprecated:
Use isAutoNormalize() instead.

Definition at line 379 of file versekey.h.

379 { return isAutoNormalize()?1:0; } // deprecated
virtual bool isAutoNormalize() const
Definition: versekey.cpp:1643
SWDEPRECATED char VerseKey::Book ( ) const
inline
Deprecated:
Use getBook() instead.

Definition at line 276 of file versekey.h.

276 { return getBook(); } // deprecated
virtual char getBook() const
Definition: versekey.cpp:1510
SWDEPRECATED char VerseKey::Book ( char  ibook)
inline
Deprecated:
Use setBook() instead.

Definition at line 325 of file versekey.h.

325 { char retVal = getBook(); setBook(ibook); return retVal; } // deprecated
virtual char getBook() const
Definition: versekey.cpp:1510
virtual void setBook(char ibook)
Definition: versekey.cpp:1565
SWDEPRECATED int VerseKey::Chapter ( ) const
inline
Deprecated:
Use getChapter() instead.

Definition at line 287 of file versekey.h.

287 { return getChapter(); } // deprecated
virtual int getChapter() const
Definition: versekey.cpp:1522
SWDEPRECATED int VerseKey::Chapter ( int  ichapter)
inline
Deprecated:
Use setChapter() instead.

Definition at line 335 of file versekey.h.

335 { char retVal = getChapter(); setChapter(ichapter); return retVal; } // deprecated
virtual void setChapter(int ichapter)
Definition: versekey.cpp:1603
virtual int getChapter() const
Definition: versekey.cpp:1522
void VerseKey::checkBounds ( )
private

Definition at line 1741 of file versekey.cpp.

1741  {
1742 
1743  long i = getIndex();
1744 
1745  initBounds();
1746  if (i > upperBound) {
1748  i = getIndex();
1750  }
1751  if (i < lowerBound) {
1754  }
1755 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
void initBounds() const
Definition: versekey.cpp:1209
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
char error
Definition: swkey.h:106
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
virtual long getIndex() const
Definition: versekey.cpp:1681
void VerseKey::clearBounds ( ) const
virtual

clears the boundaries of this VerseKey

Reimplemented from SWKey.

Definition at line 1202 of file versekey.cpp.

1202  {
1203  delete tmpClone;
1204  tmpClone = 0;
1205  boundSet = false;
1206 }
bool boundSet
Definition: swkey.h:104
VerseKey * tmpClone
Definition: versekey.h:85
SWDEPRECATED void VerseKey::ClearBounds ( )
inline
Deprecated:
Use clearBounds

Definition at line 208 of file versekey.h.

208 { clearBounds(); }
void clearBounds() const
Definition: versekey.cpp:1202
SWKey * VerseKey::clone ( ) const
virtual

Creates a new SWKey based on the current VerseKey see also the Copy Constructor

Reimplemented from SWKey.

Reimplemented in VerseTreeKey.

Definition at line 278 of file versekey.cpp.

279 {
280  return new VerseKey(*this);
281 }
VerseKey(const char *ikey=0)
Definition: versekey.cpp:105
int VerseKey::compare ( const SWKey ikey)
virtual

Compares another SWKey object

Parameters
ikeykey 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 1768 of file versekey.cpp.

1769 {
1770  const SWKey *testKey = &ikey;
1771  const VerseKey *vkey = (const VerseKey *)SWDYNAMIC_CAST(const VerseKey, testKey);
1772  if (vkey) {
1773  return _compare(*vkey);
1774  }
1775  const VerseKey ivkey = (const char *)ikey;
1776  return _compare(ivkey);
1777 }
virtual int _compare(const VerseKey &ikey)
Definition: versekey.cpp:1790
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
Definition: swkey.h:77
const char * VerseKey::convertToOSIS ( const char *  inRef,
const SWKey defaultKey 
)
static

Tries to parse a string and convert it into an OSIS reference

Parameters
inRefreference string to try to parse
defaultKeyfor details
See Also
ParseVerseList(..., defaultKey, ...)

Definition at line 1887 of file versekey.cpp.

1887  {
1888  static SWBuf outRef;
1889 
1890  outRef = "";
1891 
1892  VerseKey defLanguage;
1893  ListKey verses = defLanguage.parseVerseList(inRef, (*lastKnownKey), true);
1894  const char *startFrag = inRef;
1895  for (int i = 0; i < verses.getCount(); i++) {
1896  SWKey *element = verses.getElement(i);
1897 // VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i));
1898  SWBuf buf;
1899  // TODO: This code really needs to not use fixed size arrays
1900  char frag[800];
1901  char preJunk[800];
1902  char postJunk[800];
1903  memset(frag, 0, 800);
1904  memset(preJunk, 0, 800);
1905  memset(postJunk, 0, 800);
1906  while ((*startFrag) && (strchr(" {}:;,()[].", *startFrag))) {
1907  outRef += *startFrag;
1908  startFrag++;
1909  }
1910  memmove(frag, startFrag, (size_t)((const char *)element->userData - startFrag) + 1);
1911  frag[((const char *)element->userData - startFrag) + 1] = 0;
1912  int j;
1913  for (j = strlen(frag)-1; j && (strchr(" {}:;,()[].", frag[j])); j--);
1914  if (frag[j+1])
1915  strcpy(postJunk, frag+j+1);
1916  frag[j+1]=0;
1917  startFrag += ((const char *)element->userData - startFrag) + 1;
1918  buf = "<reference osisRef=\"";
1919  buf += element->getOSISRefRangeText();
1920  buf += "\">";
1921  buf += frag;
1922  buf += "</reference>";
1923  buf += postJunk;
1924 
1925  outRef += buf;
1926 
1927  }
1928  if (startFrag < (inRef + strlen(inRef)))
1929  outRef += startFrag;
1930  return outRef.c_str();
1931 }
virtual int getCount() const
Definition: listkey.cpp:211
Definition: swbuf.h:47
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
const char * c_str() const
Definition: swbuf.h:158
virtual ListKey parseVerseList(const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
Definition: versekey.cpp:515
virtual const char * getOSISRefRangeText() const
Definition: swkey.cpp:203
SW_u64 userData
Definition: swkey.h:115
Definition: swkey.h:77
void VerseKey::copyFrom ( const SWKey ikey)
virtual

Copies as much info (position, range, etc.) as possible from another SWKey object

Parameters
ikeyother SWKey object from which to copy

Reimplemented from SWKey.

Definition at line 239 of file versekey.cpp.

239  {
240  // check to see if we can do a more specific copy
241  // plus some optimizations
242  const SWKey *fromKey = &ikey;
243  const ListKey *tryList = SWDYNAMIC_CAST(const ListKey, fromKey);
244  if (tryList) {
245  const SWKey *k = tryList->getElement();
246  if (k) fromKey = k;
247  }
248  const VerseKey *tryVerse = SWDYNAMIC_CAST(const VerseKey, fromKey);
249  if (tryVerse) {
250  copyFrom(*tryVerse);
251  }
252  else {
253  SWKey::copyFrom(*fromKey);
254 // extraneous parse which inadvertently clears error flag
255 // SWKey::copyFrom already calls setText, which VerseKey::setText already calls parse()
256 // parse();
257  }
258 }
virtual void copyFrom(const SWKey &ikey)
Definition: versekey.cpp:239
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
virtual void copyFrom(const SWKey &ikey)
Definition: swkey.cpp:173
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
Definition: swkey.h:77
void VerseKey::copyFrom ( const VerseKey ikey)
virtual

Equates this VerseKey to another VerseKey

Definition at line 218 of file versekey.cpp.

218  {
219  autonorm = ikey.autonorm;
220  intros = ikey.intros;
221  testament = ikey.getTestament();
222  book = ikey.getBook();
223  chapter = ikey.getChapter();
224  verse = ikey.getVerse();
225  suffix = ikey.getSuffix();
226  setLocale(ikey.getLocale());
228  if (ikey.isBoundSet()) {
231  }
232 }
virtual bool isBoundSet() const
Definition: swkey.h:189
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
virtual char getSuffix() const
Definition: versekey.cpp:1630
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual void setVersificationSystem(const char *name)
Definition: versekey.cpp:298
virtual const char * getVersificationSystem() const
Definition: versekey.cpp:316
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
signed char book
Definition: versekey.h:96
char autonorm
Definition: versekey.h:65
void setLocale(const char *name)
Definition: swkey.h:225
char * getLocale() const
Definition: swkey.h:224
virtual char getTestament() const
Definition: versekey.cpp:1498
void VerseKey::decrement ( int  steps = 1)
virtual

Decrements key a number of verses

Parameters
stepsNumber of verses to jump backward

Reimplemented from SWKey.

Reimplemented in VerseTreeKey.

Definition at line 1374 of file versekey.cpp.

1374  {
1375  // if we're not autonormalizing and we're already not normalized
1376  if (!autonorm && chapter > 0 && verse > getVerseMax()) {
1377  verse -= step;
1378  checkBounds();
1379  return;
1380  }
1381  char ierror = 0;
1382  setIndex(getIndex() - step);
1383  while ((!verse) && (!intros) && (!ierror)) {
1384  setIndex(getIndex() - 1);
1385  ierror = popError();
1386  }
1387  if ((ierror) && (!intros))
1388  (*this)++;
1389 
1390  error = (ierror) ? ierror : error;
1391 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
signed int chapter
Definition: versekey.h:97
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual char popError()
Definition: swkey.cpp:147
virtual int getVerseMax() const
Definition: versekey.cpp:1333
char error
Definition: swkey.h:106
char autonorm
Definition: versekey.h:65
void checkBounds()
Definition: versekey.cpp:1741
virtual long getIndex() const
Definition: versekey.cpp:1681
virtual bool SWKey::equals ( const SWKey ikey)
inlinevirtualinherited

test equality of this SWKey object's position with another SWKey

Parameters
ikeykey to compare with this one
Returns
true if the key positions are equal

Definition at line 204 of file swkey.h.

204 { return !compare(ikey); }
virtual int compare(const SWKey &ikey)
Definition: swkey.cpp:218
SWDEPRECATED char SWKey::Error ( )
inlineinherited
Deprecated:
Use popError and getError instead

Definition at line 169 of file swkey.h.

169 { return popError(); }
virtual char popError()
Definition: swkey.cpp:147
void VerseKey::freshtext ( ) const
protected

Refresh keytext based on testament|book|chapter|verse default auto normalization to true default display headings option is false

Definition at line 357 of file versekey.cpp.

358 {
359  char buf[2024];
360  int realTest = testament;
361  int realbook = book;
362 
363  if (book < 1) {
364  if (testament < 1)
365  sprintf(buf, "[ Module Heading ]");
366  else sprintf(buf, "[ Testament %d Heading ]", (int)testament);
367  }
368  else {
369  if (realbook > BMAX[realTest-1]) {
370  realbook -= BMAX[realTest-1];
371  if (realTest < 2)
372  realTest++;
373  if (realbook > BMAX[realTest-1])
374  realbook = BMAX[realTest-1];
375  }
376  sprintf(buf, "%s %d:%d", getBookName(), chapter, verse);
377  if (suffix) {
378  buf[strlen(buf)+1] = 0;
379  buf[strlen(buf)] = suffix;
380  }
381  }
382 
383  stdstr((char **)&keytext, buf);
384 }
signed int chapter
Definition: versekey.h:97
virtual const char * getBookName() const
Definition: versekey.cpp:1265
signed char testament
Definition: versekey.h:95
char * keytext
Definition: swkey.h:102
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
signed char book
Definition: versekey.h:96
int BMAX[2]
Definition: versekey.h:120
char VerseKey::getBook ( ) const
virtual

Gets book

Returns
value of book

Definition at line 1510 of file versekey.cpp.

1511 {
1512  return book;
1513 }
signed char book
Definition: versekey.h:96
const char * VerseKey::getBookAbbrev ( ) const
virtual

Definition at line 1275 of file versekey.cpp.

1275  {
1276  return getPrivateLocale()->translate((SWBuf("prefAbbr_")+refSys->getBook(((testament>1)?BMAX[0]:0)+book-1)->getPreferredAbbreviation()).c_str());
1277 }
Definition: swbuf.h:47
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
const Book * getBook(int number) const
const char * getPreferredAbbreviation() const
virtual const char * translate(const char *text)
Definition: swlocale.cpp:106
SWLocale * getPrivateLocale() const
Definition: swkey.cpp:111
signed char book
Definition: versekey.h:96
int BMAX[2]
Definition: versekey.h:120
int VerseKey::getBookFromAbbrev ( const char *  abbr) const
protectedvirtual

Reimplemented in VerseTreeKey.

Definition at line 396 of file versekey.cpp.

397 {
398  int diff, abLen, min, max, target, retVal = -1;
399 
400  char *abbr = 0;
401 
402  int abbrevsCnt;
403 
404  const struct abbrev *abbrevs = getPrivateLocale()->getBookAbbrevs(&abbrevsCnt);
405 
407  const bool hasUTF8Support = StringMgr::hasUTF8Support();
408 
409  // The first iteration of this loop tries to uppercase
410  // the string. If we still fail to match, we try
411  // matching the string without any toupper logic.
412  // This is useful for, say, Chinese user input
413  // on a system that doesn't properly support
414  // a true Unicode-toupper function (!hasUTF8Support)
415  for (int i = 0; i < 2; i++) {
416  stdstr(&abbr, iabbr, 2);
417  strstrip(abbr);
418 
419  if (!i) {
420  if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales
421  stringMgr->upperUTF8(abbr, (unsigned int)(strlen(abbr)*2));
422  }
423  else {
424  stringMgr->upperLatin1(abbr);
425  }
426  }
427 
428  abLen = (int)strlen(abbr);
429 
430  if (abLen) {
431  min = 0;
432  max = abbrevsCnt;
433 
434  // binary search for a match
435  while(1) {
436  target = min + ((max - min) / 2);
437  diff = strncmp(abbr, abbrevs[target].ab, abLen);
438  if ((!diff)||(target >= max)||(target <= min))
439  break;
440  if (diff > 0)
441  min = target;
442  else max = target;
443  }
444 
445  // lets keep backing up till we find the 'first' valid match
446  for (; target > 0; target--) {
447  if (strncmp(abbr, abbrevs[target-1].ab, abLen))
448  break;
449  }
450 
451  if (!diff) {
452  // lets keep moving forward till we find an abbrev in our refSys
453  retVal = refSys->getBookNumberByOSISName(abbrevs[target].osis);
454  while ((retVal < 0) && (target < max) && (!strncmp(abbr, abbrevs[target+1].ab, abLen))) {
455  target++;
456  retVal = refSys->getBookNumberByOSISName(abbrevs[target].osis);
457  }
458  }
459  else retVal = -1;
460  }
461  if (retVal > 0)
462  break;
463  }
464  delete [] abbr;
465  return retVal;
466 }
static bool hasUTF8Support()
Definition: stringmgr.h:58
virtual struct abbrev * getBookAbbrevs(int *retSize)
Definition: swlocale.cpp:178
const VersificationMgr::System * refSys
Definition: versekey.h:61
const char * ab
static StringMgr * getSystemStringMgr()
Definition: stringmgr.cpp:197
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
virtual char * upperUTF8(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:223
int getBookNumberByOSISName(const char *bookName) const
SWLocale * getPrivateLocale() const
Definition: swkey.cpp:111
char * strstrip(char *istr)
Definition: utilstr.cpp:118
virtual char * upperLatin1(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:327
const char * osis
virtual int VerseKey::getBookMax ( ) const
inlinevirtual

Definition at line 277 of file versekey.h.

277 { return BMAX[testament-1]; }
signed char testament
Definition: versekey.h:95
int BMAX[2]
Definition: versekey.h:120
const char * VerseKey::getBookName ( ) const
virtual

Get/Set position of this key by Book Name

Definition at line 1265 of file versekey.cpp.

1265  {
1266  return getPrivateLocale()->translate(refSys->getBook(((testament>1)?BMAX[0]:0)+book-1)->getLongName());
1267 }
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
const Book * getBook(int number) const
virtual const char * translate(const char *text)
Definition: swlocale.cpp:106
SWLocale * getPrivateLocale() const
Definition: swkey.cpp:111
signed char book
Definition: versekey.h:96
const char * getLongName() const
int BMAX[2]
Definition: versekey.h:120
int VerseKey::getChapter ( ) const
virtual

Gets chapter

Returns
value of chapter

Definition at line 1522 of file versekey.cpp.

1523 {
1524  return chapter;
1525 }
signed int chapter
Definition: versekey.h:97
int VerseKey::getChapterMax ( ) const
virtual

Definition at line 1327 of file versekey.cpp.

1327  {
1328  if (book < 1) return 0;
1329  const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
1330  return (b) ? b->getChapterMax() : -1;
1331 }
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
const Book * getBook(int number) const
signed char book
Definition: versekey.h:96
int BMAX[2]
Definition: versekey.h:120
const SWClass* SWObject::getClass ( ) const
inlineinherited

Use this to get the class definition and inheritance order.

Returns
The class definition of this object

Definition at line 63 of file swobject.h.

63  {
64  return myClass;
65  }
const SWClass * myClass
Definition: swobject.h:55
virtual char SWKey::getError ( ) const
inlinevirtualinherited

Definition at line 164 of file swkey.h.

164 { return error; }
char error
Definition: swkey.h:106
long VerseKey::getIndex ( ) const
virtual

Gets index based upon current verse

Returns
offset

Reimplemented from SWKey.

Definition at line 1681 of file versekey.cpp.

1682 {
1683  long offset;
1684 
1685  if (!testament) { // if we want module heading
1686  offset = 0;
1687  }
1688  else if (!book) { // we want testament heading
1689  offset = ((testament == 2) ? refSys->getNTStartOffset():0) + 1;
1690  }
1691  else {
1692  offset = refSys->getOffsetFromVerse((((testament>1)?BMAX[0]:0)+book-1), chapter, verse);
1693  }
1694  return offset;
1695 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
long getOffsetFromVerse(int book, int chapter, int verse) const
const VersificationMgr::System * refSys
Definition: versekey.h:61
signed int verse
Definition: versekey.h:98
signed char book
Definition: versekey.h:96
int BMAX[2]
Definition: versekey.h:120
char* SWKey::getLocale ( ) const
inlineinherited

Definition at line 224 of file swkey.h.

224 { return localeName; }
char * localeName
Definition: swkey.h:108
VerseKey & VerseKey::getLowerBound ( ) const

gets the lower boundary of this VerseKey

Returns
the lower boundary of this VerseKey

Definition at line 1156 of file versekey.cpp.

1157 {
1158  initBounds();
1159  if (!isAutoNormalize()) {
1165  }
1166  else {
1169  }
1170 
1171  return (*tmpClone);
1172 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
signed int chapter
Definition: versekey.h:97
VerseComponents lowerBoundComponents
Definition: versekey.h:89
signed char testament
Definition: versekey.h:95
virtual bool isAutoNormalize() const
Definition: versekey.cpp:1643
virtual void setSuffix(char isuffix)
Definition: versekey.cpp:1634
virtual void setVerse(int iverse)
Definition: versekey.cpp:1622
void initBounds() const
Definition: versekey.cpp:1209
signed char book
Definition: versekey.h:96
VerseKey * tmpClone
Definition: versekey.h:85
long lowerBound
Definition: versekey.h:84
const char * VerseKey::getOSISBookName ( ) const
virtual

Definition at line 1270 of file versekey.cpp.

1270  {
1271  return refSys->getBook(((testament>1)?BMAX[0]:0)+book-1)->getOSISName();
1272 }
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
const Book * getBook(int number) const
const char * getOSISName() const
signed char book
Definition: versekey.h:96
int BMAX[2]
Definition: versekey.h:120
const char * VerseKey::getOSISRef ( ) const
virtual

Definition at line 1810 of file versekey.cpp.

1810  {
1811  static char buf[5][254];
1812  static int loop = 0;
1813 
1814  if (loop > 4)
1815  loop = 0;
1816 
1817  if (getVerse())
1818  sprintf(buf[loop], "%s.%d.%d", getOSISBookName(), getChapter(), getVerse());
1819  else if (getChapter())
1820  sprintf(buf[loop], "%s.%d", getOSISBookName(), getChapter());
1821  else if (getBook())
1822  sprintf(buf[loop], "%s", getOSISBookName());
1823  else buf[loop][0] = 0;
1824  return buf[loop++];
1825 }
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
virtual const char * getOSISBookName() const
Definition: versekey.cpp:1270
const char * VerseKey::getOSISRefRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 1873 of file versekey.cpp.

1873  {
1874  if (isBoundSet() && (lowerBound != upperBound)) {
1875  SWBuf buf = getLowerBound().getOSISRef();
1876  buf += "-";
1877  buf += getUpperBound().getOSISRef();
1878  stdstr(&rangeText, buf.c_str());
1879  }
1880  else stdstr(&rangeText, getOSISRef());
1881  return rangeText;
1882 }
virtual bool isBoundSet() const
Definition: swkey.h:189
Definition: swbuf.h:47
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
virtual const char * getOSISRef() const
Definition: versekey.cpp:1810
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
char * rangeText
Definition: swkey.h:103
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
SWLocale * SWKey::getPrivateLocale ( ) const
protectedinherited

Definition at line 111 of file swkey.cpp.

111  {
112  if (!locale) {
113  if ((!localeCache.name) || (strcmp(localeCache.name, localeName))) {
115  // this line is the entire bit of work we're trying to avoid with the cache
116  // worth it? compare time examples/cmdline/search KJV "God love world" to
117  // same with this method reduced to:
118  // if (!local) local = ... (call below); return locale;
120  }
122  }
123  return locale;
124 }
SWLocale * locale
Definition: swkey.h:82
char * localeName
Definition: swkey.h:108
char * name
Definition: swkey.h:81
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
virtual SWLocale * getLocale(const char *name)
Definition: localemgr.cpp:210
static LocaleMgr * getSystemLocaleMgr()
Definition: localemgr.cpp:54
SWLocale * locale
Definition: swkey.h:94
static LocaleCache localeCache
Definition: swkey.h:92
const char * VerseKey::getRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 1832 of file versekey.cpp.

1832  {
1833  if (isBoundSet() && lowerBound != upperBound) {
1834  SWBuf buf = (const char *)getLowerBound();
1835  buf += "-";
1836  buf += (const char *)getUpperBound();
1837  stdstr(&rangeText, buf.c_str());
1838  }
1839  else stdstr(&rangeText, getText());
1840  return rangeText;
1841 }
virtual bool isBoundSet() const
Definition: swkey.h:189
Definition: swbuf.h:47
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
virtual const char * getText() const
Definition: versekey.cpp:1242
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
char * rangeText
Definition: swkey.h:103
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
const char * VerseKey::getShortRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 1848 of file versekey.cpp.

1848  {
1849  if (isBoundSet() && (lowerBound != upperBound)) {
1850  SWBuf buf = getLowerBound().getShortText();
1851  buf += "-";
1855  buf.appendFormatted("%d", getUpperBound().getVerse());
1856  }
1858  && getUpperBound().getBook() == getLowerBound().getBook()) {
1860  }
1861  else buf += getUpperBound().getShortText();
1862  stdstr(&rangeText, buf.c_str());
1863  }
1864  else stdstr(&rangeText, getShortText());
1865  return rangeText;
1866 }
virtual bool isBoundSet() const
Definition: swkey.h:189
SWBuf & appendFormatted(const char *format,...)
Definition: swbuf.cpp:81
Definition: swbuf.h:47
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
virtual int getChapter() const
Definition: versekey.cpp:1522
const char * c_str() const
Definition: swbuf.h:158
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
char * rangeText
Definition: swkey.h:103
virtual const char * getShortText() const
Definition: versekey.cpp:1248
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
virtual char getTestament() const
Definition: versekey.cpp:1498
const char * VerseKey::getShortText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 1248 of file versekey.cpp.

1248  {
1249  static char *stext = 0;
1250  char buf[2047];
1251  freshtext();
1252  if (book < 1) {
1253  if (testament < 1)
1254  sprintf(buf, "[ Module Heading ]");
1255  else sprintf(buf, "[ Testament %d Heading ]", (int)testament);
1256  }
1257  else {
1258  sprintf(buf, "%s %d:%d", getBookAbbrev(), chapter, verse);
1259  }
1260  stdstr(&stext, buf);
1261  return stext;
1262 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
signed int verse
Definition: versekey.h:98
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void freshtext() const
Definition: versekey.cpp:357
signed char book
Definition: versekey.h:96
virtual const char * getBookAbbrev() const
Definition: versekey.cpp:1275
char VerseKey::getSuffix ( ) const
virtual

Gets verse suffix

Returns
value of verse suffix

Definition at line 1630 of file versekey.cpp.

1630  {
1631  return suffix;
1632 }
signed char suffix
Definition: versekey.h:99
char VerseKey::getTestament ( ) const
virtual

Gets testament

Returns
value of testament

Definition at line 1498 of file versekey.cpp.

1499 {
1500  return testament;
1501 }
signed char testament
Definition: versekey.h:95
long VerseKey::getTestamentIndex ( ) const
virtual

Gets index into current testament based upon current verse

Returns
offset

Definition at line 1704 of file versekey.cpp.

1705 {
1706  long offset = getIndex();
1707  return (testament > 1) ? offset - refSys->getNTStartOffset() : offset;
1708 }
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
virtual long getIndex() const
Definition: versekey.cpp:1681
virtual int VerseKey::getTestamentMax ( ) const
inlinevirtual

Definition at line 266 of file versekey.h.

266 { return 2; }
const char * VerseKey::getText ( ) const
virtual

refreshes keytext before returning if cast to a (char *) is requested

Reimplemented from SWKey.

Definition at line 1242 of file versekey.cpp.

1242  {
1243  freshtext();
1244  return keytext;
1245 }
char * keytext
Definition: swkey.h:102
void freshtext() const
Definition: versekey.cpp:357
VerseKey & VerseKey::getUpperBound ( ) const

gets the upper boundary of this VerseKey

Returns
the upper boundary of this VerseKey

Definition at line 1179 of file versekey.cpp.

1180 {
1181  initBounds();
1182  if (!isAutoNormalize()) {
1188  }
1189  else {
1192  }
1193 
1194  return (*tmpClone);
1195 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
virtual bool isAutoNormalize() const
Definition: versekey.cpp:1643
VerseComponents upperBoundComponents
Definition: versekey.h:89
virtual void setSuffix(char isuffix)
Definition: versekey.cpp:1634
virtual void setVerse(int iverse)
Definition: versekey.cpp:1622
void initBounds() const
Definition: versekey.cpp:1209
signed char book
Definition: versekey.h:96
VerseKey * tmpClone
Definition: versekey.h:85
long upperBound
Definition: versekey.h:84
int VerseKey::getVerse ( ) const
virtual

Gets verse

Returns
value of verse

Definition at line 1534 of file versekey.cpp.

1535 {
1536  return verse;
1537 }
signed int verse
Definition: versekey.h:98
int VerseKey::getVerseMax ( ) const
virtual

Definition at line 1333 of file versekey.cpp.

1333  {
1334  if (book < 1) return 0;
1335  const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
1336  return (b) ? b->getVerseMax(chapter) : -1;
1337 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
const Book * getBook(int number) const
signed char book
Definition: versekey.h:96
int getVerseMax(int chapter) const
int BMAX[2]
Definition: versekey.h:120
const char * VerseKey::getVersificationSystem ( ) const
virtual

Definition at line 316 of file versekey.cpp.

316 { return refSys->getName(); }
const VersificationMgr::System * refSys
Definition: versekey.h:61
const char * getName() const
SWDEPRECATED char VerseKey::Headings ( char  iheadings = MAXPOS(char))
inline

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

Deprecated:
Use setIntros() and isIntros() instead.
Parameters
iheadingsvalue which to set intros [MAXPOS(char)] - only get
Returns
if unchanged -> value of intros, if changed -> previous value of intros

Definition at line 391 of file versekey.h.

391 { char retVal = isIntros(); if (iheadings != MAXPOS(char)) setIntros(iheadings!=0); return retVal; }
virtual bool isIntros() const
Definition: versekey.cpp:1669
virtual void setIntros(bool val)
Definition: versekey.cpp:1663
#define MAXPOS(x)
Definition: swmacs.h:30
void VerseKey::increment ( int  steps = 1)
virtual

Increments key a number of verses

Parameters
stepsNumber of verses to jump forward

Reimplemented from SWKey.

Reimplemented in VerseTreeKey.

Definition at line 1348 of file versekey.cpp.

1348  {
1349  // if we're not autonormalizing and we're already not normalized
1350  if (!autonorm && chapter > 0 && verse > getVerseMax()) {
1351  verse += step;
1352  checkBounds();
1353  return;
1354  }
1355  char ierror = 0;
1356  setIndex(getIndex() + step);
1357  while ((!verse) && (!intros) && (!ierror)) {
1358  setIndex(getIndex() + 1);
1359  ierror = popError();
1360  }
1361 
1362  error = (ierror) ? ierror : error;
1363 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
signed int chapter
Definition: versekey.h:97
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual char popError()
Definition: swkey.cpp:147
virtual int getVerseMax() const
Definition: versekey.cpp:1333
char error
Definition: swkey.h:106
char autonorm
Definition: versekey.h:65
void checkBounds()
Definition: versekey.cpp:1741
virtual long getIndex() const
Definition: versekey.cpp:1681
void VerseKey::init ( const char *  v11n = "KJV")
private

initializes this VerseKey()

Definition at line 56 of file versekey.cpp.

56  {
57  myClass = &classdef;
58 
59  instance++;
60  autonorm = 1; // default auto normalization to true
61  intros = false; // default display intros option is false
62  upperBound = 0;
63  lowerBound = 0;
64  boundSet = false;
65  testament = 1;
66  book = 1;
67  chapter = 1;
68  verse = 1;
69  suffix = 0;
70  tmpClone = 0;
71  refSys = 0;
72 
74 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
const SWClass * myClass
Definition: swobject.h:55
signed char suffix
Definition: versekey.h:99
const VersificationMgr::System * refSys
Definition: versekey.h:61
SWBuf v11n
Definition: osis2mod.cpp:107
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
bool boundSet
Definition: swkey.h:104
static int instance
Definition: versekey.h:58
virtual void setVersificationSystem(const char *name)
Definition: versekey.cpp:298
static const SWClass classdef(classes)
signed char book
Definition: versekey.h:96
char autonorm
Definition: versekey.h:65
VerseKey * tmpClone
Definition: versekey.h:85
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
void VerseKey::initBounds ( ) const
private

Definition at line 1209 of file versekey.cpp.

1209  {
1210  if (!tmpClone) {
1211  tmpClone = (VerseKey *)this->clone();
1212  tmpClone->setAutoNormalize(false);
1213  tmpClone->setIntros(true);
1214  tmpClone->setTestament((BMAX[1])?2:1);
1215  tmpClone->setBook(BMAX[(BMAX[1])?1:0]);
1224 
1225  lowerBound = 0;
1231 
1232  }
1233  else tmpClone->setLocale(getLocale());
1234 }
virtual int getChapterMax() const
Definition: versekey.cpp:1327
virtual SWKey * clone() const
Definition: versekey.cpp:278
VerseComponents lowerBoundComponents
Definition: versekey.h:89
virtual void setChapter(int ichapter)
Definition: versekey.cpp:1603
virtual void setTestament(char itestament)
Definition: versekey.cpp:1548
virtual char getSuffix() const
Definition: versekey.cpp:1630
VerseComponents upperBoundComponents
Definition: versekey.h:89
virtual void setIntros(bool val)
Definition: versekey.cpp:1663
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual void setVerse(int iverse)
Definition: versekey.cpp:1622
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
virtual int getVerseMax() const
Definition: versekey.cpp:1333
virtual void setBook(char ibook)
Definition: versekey.cpp:1565
VerseKey * tmpClone
Definition: versekey.h:85
int BMAX[2]
Definition: versekey.h:120
long lowerBound
Definition: versekey.h:84
virtual void setAutoNormalize(bool iautonorm)
Definition: versekey.cpp:1648
void setLocale(const char *name)
Definition: swkey.h:225
long upperBound
Definition: versekey.h:84
char * getLocale() const
Definition: swkey.h:224
virtual char getTestament() const
Definition: versekey.cpp:1498
virtual long getIndex() const
Definition: versekey.cpp:1681
bool VerseKey::isAutoNormalize ( ) const
virtual

Definition at line 1643 of file versekey.cpp.

1644 {
1645  return autonorm;
1646 }
char autonorm
Definition: versekey.h:65
virtual bool SWKey::isBoundSet ( ) const
inlinevirtualinherited

Definition at line 189 of file swkey.h.

189 { return boundSet; }
bool boundSet
Definition: swkey.h:104
bool VerseKey::isIntros ( ) const
virtual

Definition at line 1669 of file versekey.cpp.

1670 {
1671  return intros;
1672 }
char intros
Definition: versekey.h:69
bool SWKey::isPersist ( ) const
inherited

Gets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.

Returns
1 - persists in module; 0 - a copy is attempted

Definition at line 99 of file swkey.cpp.

100 {
101  return persist;
102 }
bool persist
Definition: swkey.h:105
virtual bool VerseKey::isTraversable ( ) const
inlinevirtual

Whether or not this key can be ++ – incremented

Reimplemented from SWKey.

Reimplemented in VerseTreeKey.

Definition at line 249 of file versekey.h.

249 { return true; }
SWDEPRECATED VerseKey& VerseKey::LowerBound ( const VerseKey lb)
inline
Deprecated:
Use setLowerBound / getLowerBound

Definition at line 173 of file versekey.h.

173 { setLowerBound(lb); return getLowerBound(); }
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
SWDEPRECATED VerseKey& VerseKey::LowerBound ( ) const
inline
Deprecated:
Use getLowerBound

Definition at line 191 of file versekey.h.

191 { return getLowerBound(); }
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
void VerseKey::normalize ( bool  autocheck = false)
virtual

checks limits and normalizes if necessary (e.g. Matthew 29:47 = Mark 2:2). If last verse is exceeded, key is set to last Book CH:VS

Definition at line 1401 of file versekey.cpp.

1402 {
1403 
1404  if ((!autocheck || autonorm) // only normalize if we were explicitely called or if autonorm is turned on
1405  ) {
1406  error = 0;
1407 
1408  while ((testament < 3) && (testament > 0)) {
1409 
1410 
1411  if (book > BMAX[testament-1]) {
1412  book -= (BMAX[testament-1] + (intros?1:0));
1413  testament++;
1414  continue;
1415  }
1416  if (book < (intros?0:1)) {
1417  if (--testament > 0) {
1418  book += (BMAX[testament-1] + (intros?1:0));
1419  }
1420  continue;
1421  }
1422 
1423 
1424  if (chapter > getChapterMax()) {
1425  chapter -= (getChapterMax() + (intros?1:0));
1426  book++;
1427  continue;
1428  }
1429  if (chapter < (intros?0:1)) {
1430  --book;
1431  if (book < (intros?0:1)) {
1432  if (--testament > 0) {
1433  book += (BMAX[testament-1] + (intros?1:0));
1434  }
1435  }
1436  chapter += (getChapterMax() + (intros?1:0));
1437  continue;
1438  }
1439 
1440 
1441  if (chapter > 0 && verse > getVerseMax()) {
1442  verse -= (getVerseMax() + (intros?1:0));
1443  chapter++;
1444  continue;
1445  }
1446  if (verse < (intros?0:1)) {
1447  if (--chapter < (intros?0:1)) {
1448  --book;
1449  if (book < (intros?0:1)) {
1450  if (--testament > 0) {
1451  book += (BMAX[testament-1] + (intros?1:0));
1452  }
1453  }
1454  chapter += (getChapterMax() + (intros?1:0));
1455  }
1456  verse += (getVerseMax() + (intros?1:0));
1457  continue;
1458  }
1459 
1460  break; // If we've made it this far (all failure checks continue) we're ok
1461  }
1462 
1463  if (testament > (BMAX[1]?2:1)) {
1464  testament = BMAX[1]?2:1;
1465  book = BMAX[testament-1];
1466  chapter = getChapterMax();
1467  verse = getVerseMax();
1469  }
1470 
1471  if (testament < 1) {
1472  error = ((!intros) || (testament < 0) || (book < 0)) ? KEYERR_OUTOFBOUNDS : 0;
1473  testament = ((intros) ? 0 : 1);
1474  book = ((intros) ? 0 : 1);
1475  chapter = ((intros) ? 0 : 1);
1476  verse = ((intros) ? 0 : 1);
1477  }
1478 
1479  // should we always perform bounds checks? Tried but seems to cause infinite recursion
1480  if (_compare(getUpperBound()) > 0) {
1483  }
1484  if (_compare(getLowerBound()) < 0) {
1487  }
1488  }
1489 }
virtual int getChapterMax() const
Definition: versekey.cpp:1327
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
virtual void positionFrom(const SWKey &ikey)
Definition: versekey.cpp:183
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual int _compare(const VerseKey &ikey)
Definition: versekey.cpp:1790
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
virtual int getVerseMax() const
Definition: versekey.cpp:1333
signed char book
Definition: versekey.h:96
char error
Definition: swkey.h:106
char autonorm
Definition: versekey.h:65
int BMAX[2]
Definition: versekey.h:120
SWDEPRECATED void VerseKey::Normalize ( char  autocheck = 0)
inline
Deprecated:
Use normalize

Definition at line 362 of file versekey.h.

362 { normalize(autocheck!=0); }
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
virtual SWKEY_OPERATORS SWKey& VerseKey::operator= ( const VerseKey ikey)
inlinevirtual

Reimplemented in VerseTreeKey.

Definition at line 487 of file versekey.h.

487 { positionFrom(ikey); return *this; }
virtual void positionFrom(const SWKey &ikey)
Definition: versekey.cpp:183
char VerseKey::parse ( bool  checkNormalize = true)
protectedvirtual

Parse a character array into testament|book|chapter|verse

Definition at line 326 of file versekey.cpp.

327 {
328  testament = BMAX[1]?2:1;
329  book = BMAX[BMAX[1]?1:0];
330  chapter = 1;
331  verse = 1;
332 
333  int error = 0;
334 
335  if (keytext) {
336  // pass our own copy of keytext as keytext memory may be freshed during parse
337  ListKey tmpListKey = parseVerseList(SWBuf(keytext).c_str());
338  if (tmpListKey.getCount()) {
339  this->positionFrom(*tmpListKey.getElement(0));
340  error = this->error;
341  } else error = 1;
342  }
343  if (checkAutoNormalize) {
344  normalize(true);
345  }
346  freshtext();
347 
348  return (this->error) ? this->error : (this->error = error);
349 }
signed int chapter
Definition: versekey.h:97
virtual int getCount() const
Definition: listkey.cpp:211
Definition: swbuf.h:47
signed char testament
Definition: versekey.h:95
char * keytext
Definition: swkey.h:102
virtual void positionFrom(const SWKey &ikey)
Definition: versekey.cpp:183
signed int verse
Definition: versekey.h:98
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
virtual ListKey parseVerseList(const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
Definition: versekey.cpp:515
void freshtext() const
Definition: versekey.cpp:357
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
signed char book
Definition: versekey.h:96
char error
Definition: swkey.h:106
int BMAX[2]
Definition: versekey.h:120
ListKey VerseKey::parseVerseList ( const char *  buf,
const char *  defaultKey = 0,
bool  expandRange = false,
bool  useChapterAsVerse = false 
)
virtual

Definition at line 515 of file versekey.cpp.

515  {
516 
517  // hold on to our own copy of params, as threads/recursion may change outside values
518  const char *bufStart = buf;
519  SWBuf iBuf = buf;
520  buf = iBuf.c_str();
521  SWBuf iDefaultKey = defaultKey;
522  if (defaultKey) defaultKey = iDefaultKey.c_str();
523 
524  char book[2048]; // TODO: bad, remove
525  char number[2048]; // TODO: bad, remove
526  *book = 0;
527  *number = 0;
528  int tobook = 0;
529  int tonumber = 0;
530  char suffix = 0;
531  int chap = -1, verse = -1;
532  int bookno = 0;
533  int loop;
534  char comma = 0;
535  char dash = 0;
536  const char *orig = buf;
537  int q;
538  ListKey tmpListKey;
540  char lastPartial = 0;
541  bool inTerm = true;
542  int notAllDigits = 0;
543  bool doubleF = false;
544 
545  // assert we have a buffer
546  if (!buf) return internalListKey;
547 
548  VerseKey *curKey = (VerseKey *)this->clone();
549  VerseKey *lastKey = (VerseKey *)this->clone();
550  lastKey->clearBounds();
551  curKey->clearBounds();
552 
553  // some silly checks for corner cases
554  if (!strcmp(buf, "[ Module Heading ]")) {
555  curKey->setVerse(0);
556  curKey->setChapter(0);
557  curKey->setBook(0);
558  curKey->setTestament(0);
559  lastKey->setLowerBound(*curKey);
560  lastKey->setUpperBound(*curKey);
561  internalListKey << *lastKey;
562  delete curKey;
563  delete lastKey;
564  return internalListKey;
565  }
566  if ((!strncmp(buf, "[ Testament ", 12)) &&
567  (isdigit(buf[12])) &&
568  (!strcmp(buf+13, " Heading ]"))) {
569  curKey->setVerse(0);
570  curKey->setChapter(0);
571  curKey->setBook(0);
572  curKey->setTestament(buf[12]-48);
573  lastKey->setLowerBound(*curKey);
574  lastKey->setUpperBound(*curKey);
575  internalListKey << *lastKey;
576  delete curKey;
577  delete lastKey;
578  return internalListKey;
579  }
580 
582  lastKey->setAutoNormalize(false);
583  if (defaultKey) *lastKey = defaultKey;
584 
585  while (*buf) {
586  switch (*buf) {
587  case ':':
588  if (buf[1] != ' ') { // for silly "Mat 1:1: this verse...."
589  number[tonumber] = 0;
590  tonumber = 0;
591  if (*number) {
592  if (chap >= 0)
593  verse = atoi(number);
594  else chap = atoi(number);
595  }
596  *number = 0;
597  comma = 0;
598  break;
599  }
600  goto terminate_range;
601  // otherwise drop down to next case
602  case ' ':
603  inTerm = true;
604  while (true) {
605  if ((!*number) || (chap < 0))
606  break;
607  for (q = 1; ((buf[q]) && (buf[q] != ' ')); q++);
608  if (buf[q] == ':')
609  break;
610  inTerm = false;
611  break;
612  }
613  if (inTerm) {
614  if (tobook < 1 || book[tobook-1] != ' ') {
615  book[tobook++] = ' ';
616  }
617  break;
618  }
619 
620  case '-':
621  if (chap == -1) {
622  book[tobook] = *buf;
623  book[tobook+1] = *(buf+1);
624  book[tobook+2] = 0;
625  int bookno = getBookFromAbbrev(book);
626  if (bookno > -1) {
627  tobook++;
628  buf++;
629  break;
630  }
631  }
632  case ',': // on number new verse
633  case ';': // on number new chapter
634 terminate_range:
635  number[tonumber] = 0;
636  tonumber = 0;
637  if (*number) {
638  if (chap >= 0)
639  verse = atoi(number);
640  else chap = atoi(number);
641  }
642  *number = 0;
643  book[tobook] = 0;
644  tobook = 0;
645  bookno = -1;
646  if (*book) {
647  loop = (int)strlen(book) - 1;
648 
649  for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
650 
651  if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
652  book[loop--] = 0;
653  }
654  for (; loop+1; loop--) {
655  if ((isdigit(book[loop])) || (book[loop] == ' ')) {
656  book[loop] = 0;
657  continue;
658  }
659  else {
660  if ((SW_toupper(book[loop])=='F')&&(loop)) {
661  if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) {
662  book[loop] = 0;
663  continue;
664  }
665  }
666  }
667  break;
668  }
669 
670  for (loop = (int)strlen(book) - 1; loop+1; loop--) {
671  if (book[loop] == ' ') {
672  // "PS C" is ok, but "II C" is not ok
673  if (isRoman(&book[loop+1]) && !isRoman(book,loop)) {
674  if (verse == -1) {
675  verse = chap;
676  chap = fromRoman(&book[loop+1]);
677  book[loop] = 0;
678  }
679  }
680  break;
681  }
682  }
683 
684  // check for special inscriptio and subscriptio which are saved as book intro and chap 1 intro (for INTF)
685  for (loop = (int)strlen(book) - 1; loop+1; loop--) {
686  if (book[loop] == ' ') {
687  if (!strnicmp(&book[loop+1], "inscriptio", (int)strlen(&book[loop+1]))) {
688  book[loop] = 0;
689  verse = 0;
690  chap = 0;
691  }
692  else if (!strnicmp(&book[loop+1], "subscriptio", (int)strlen(&book[loop+1]))) {
693  book[loop] = 0;
694  verse = 0;
695  chap = 1;
696  }
697  break;
698  }
699  }
700 
701  if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev
702  if (verse == -1) {
703  verse = chap;
704  chap = lastKey->getChapter();
705  *book = 0;
706  }
707  }
708  if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
709  strcpy(book, lastKey->getBookName());
710  }
711  bookno = getBookFromAbbrev(book);
712  if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) {
713  suffix = 0;
714  }
715  }
716  if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
717  char partial = 0;
718  curKey->setVerse(1);
719  curKey->setChapter(1);
720  curKey->setBook(1);
721 
722  if (bookno < 0) {
723  curKey->setTestament(lastKey->getTestament());
724  curKey->setBook(lastKey->getBook());
725  }
726  else {
727  int t = 1;
728  if (bookno > BMAX[0]) {
729  t++;
730  bookno -= BMAX[0];
731  }
732  curKey->setTestament(t);
733  curKey->setBook(bookno);
734  }
735 
736 
737  if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
738 // if (comma) {
739  curKey->setChapter(lastKey->getChapter());
740  curKey->setVerse(chap); // chap because this is the first number captured
741  if (suffix) {
742  curKey->setSuffix(suffix);
743  }
744  }
745  else {
746  if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->getChapterMax() == 1) {
747  verse = chap;
748  chap = 1;
749  }
750 
751 
752  if (chap >= 0) {
753  curKey->setChapter(chap);
754  }
755  else {
756  partial++;
757  curKey->setChapter(1);
758  }
759  if (verse >= 0) {
760  curKey->setVerse(verse);
761  if (suffix) {
762  curKey->setSuffix(suffix);
763  }
764  }
765  else {
766  partial++;
767  curKey->setVerse(1);
768  }
769  }
770 
771  // check for '-'
772  for (q = 0; ((buf[q]) && (buf[q] == ' ')); q++);
773  if ((buf[q] == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
774  buf+=q;
775  lastKey->setLowerBound(*curKey);
776  lastKey->setPosition(TOP);
777  tmpListKey << *lastKey;
778  ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
779  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
780  }
781  else {
782  if (!dash) { // if last separator was not a dash just add
783  if (expandRange && partial) {
784  lastKey->setLowerBound(*curKey);
785  if (partial > 1)
786  curKey->setPosition(MAXCHAPTER);
787  if (partial > 0)
788  *curKey = MAXVERSE;
789  lastKey->setUpperBound(*curKey);
790  *lastKey = TOP;
791  tmpListKey << *lastKey;
792  ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
793  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
794  }
795  else {
796  bool f = false;
797  if (curKey->getSuffix() == 'f') {
798  curKey->setSuffix(0);
799  f = true;
800  }
801  lastKey->setLowerBound(*curKey);
802  if (f && doubleF) (*curKey) = MAXVERSE;
803  else if (f) (*curKey)++;
804  lastKey->setUpperBound(*curKey);
805  *lastKey = TOP;
806  tmpListKey << *lastKey;
807  ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
808  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
809  }
810  }
811  else if (expandRange) {
812  VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
813  if (newElement) {
814  if (partial > 1)
815  *curKey = MAXCHAPTER;
816  if (partial > 0)
817  *curKey = MAXVERSE;
818  newElement->setUpperBound(*curKey);
819  *lastKey = *curKey;
820  *newElement = TOP;
821  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
822  }
823  }
824  }
825  lastPartial = partial;
826  }
827  *book = 0;
828  chap = -1;
829  verse = -1;
830  suffix = 0;
831  if (*buf == ',')
832  comma = 1;
833  else comma = 0;
834  if (*buf == '-')
835  dash = 1;
836  else dash = 0;
837  break;
838  case 10: // ignore these
839  case 13:
840  case '[':
841  case ']':
842  case '(':
843  case ')':
844  case '{':
845  case '}':
846  break;
847  case '.':
848  if (buf > orig) { // ignore (break) if preceeding char is not a digit
849  for (notAllDigits = tobook; notAllDigits; notAllDigits--) {
850  if ((!isdigit(book[notAllDigits-1])) && (!strchr(" .", book[notAllDigits-1])))
851  break;
852  }
853  if (!notAllDigits && !isdigit(buf[1]))
854  break;
855  }
856 
857  number[tonumber] = 0;
858  tonumber = 0;
859  if (*number) {
860  if (chap >= 0)
861  verse = atoi(number);
862  else chap = atoi(number);
863  *number = 0;
864  }
865  else if (chap == -1 && (tobook < 1 || book[tobook-1] != ' ')) {
866  book[tobook++] = ' ';
867  }
868 
869  break;
870 
871  default:
872  if (isdigit(*buf)) {
873  number[tonumber++] = *buf;
874  suffix = 0;
875  doubleF = 0;
876  }
877  else {
878  switch (*buf) {
879  case ' ': // ignore these and don't reset number
880  case 'F':
881  break;
882  default:
883  // suffixes (and oddly 'f'-- ff.)
884  if ((*buf >= 'a' && *buf <= 'z' && (chap >=0 || bookno > -1 || lastKey->isBoundSet()))
885  || *buf == 'f') {
886  // if suffix is already an 'f', then we need to mark if we're doubleF.
887  doubleF = (*buf == 'f' && suffix == 'f');
888  if (suffix && !doubleF) {
889  // 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'
890  number[tonumber] = 0;
891  tonumber = 0;
892  }
893  suffix = *buf;
894  }
895  else {
896  number[tonumber] = 0;
897  tonumber = 0;
898  }
899  break;
900  }
901  }
902  if (chap == -1)
903  book[tobook++] = *buf;
904  }
905  buf++;
906  }
907  number[tonumber] = 0;
908  tonumber = 0;
909  if (*number) {
910  if (chap >= 0)
911  verse = atoi(number);
912  else chap = atoi(number);
913  }
914  *number = 0;
915  book[tobook] = 0;
916  tobook = 0;
917  if (*book) {
918  loop = (int)strlen(book) - 1;
919 
920  // strip trailing spaces
921  for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
922 
923  // check if endsWith([0-9][a-z]) and kill the last letter, e.g., ...12a, and chop off the 'a'
924  // why? What's this for? wouldn't this mess up 2t?
925  if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
926  book[loop--] = 0;
927  }
928 
929  // skip trailing spaces and numbers
930  for (; loop+1; loop--) {
931  if ((isdigit(book[loop])) || (book[loop] == ' ')) {
932  book[loop] = 0;
933  continue;
934  }
935  else {
936  if ((SW_toupper(book[loop])=='F')&&(loop)) {
937  if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) {
938  book[loop] = 0;
939  continue;
940  }
941  }
942  }
943  break;
944  }
945 
946  // check for roman numeral chapter
947  for (loop = (int)strlen(book) - 1; loop+1; loop--) {
948  if (book[loop] == ' ') {
949  // "PS C" is ok, but "II C" is not ok
950  if (isRoman(&book[loop+1]) && !isRoman(book,loop)) {
951  if (verse == -1) {
952  verse = chap;
953  chap = fromRoman(&book[loop+1]);
954  book[loop] = 0;
955  }
956  }
957  break;
958  }
959  }
960  // check for special inscriptio and subscriptio which are saved as book intro and chap 1 intro (for INTF)
961  for (loop = (int)strlen(book) - 1; loop+1; loop--) {
962  if (book[loop] == ' ') {
963  if (!strnicmp(&book[loop+1], "inscriptio", (int)strlen(&book[loop+1]))) {
964  book[loop] = 0;
965  verse = 0;
966  chap = 0;
967  suffix = 0;
968  }
969  else if (!strnicmp(&book[loop+1], "subscriptio", (int)strlen(&book[loop+1]))) {
970  book[loop] = 0;
971  verse = 0;
972  chap = 1;
973  suffix = 0;
974  }
975  break;
976  }
977  }
978 
979  if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev.
980  if (verse == -1) {
981  verse = chap;
982  chap = lastKey->getChapter();
983  *book = 0;
984  }
985  }
986 
987  if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
988  strcpy(book, lastKey->getBookName());
989  }
990  bookno = getBookFromAbbrev(book);
991  if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) {
992  suffix = 0;
993  }
994  }
995  if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
996  char partial = 0;
997  curKey->setVerse(1);
998  curKey->setChapter(1);
999  curKey->setBook(1);
1000 
1001  if (bookno < 0) {
1002  curKey->setTestament(lastKey->getTestament());
1003  curKey->setBook(lastKey->getBook());
1004  }
1005  else {
1006  int t = 1;
1007  if (bookno > BMAX[0]) {
1008  t++;
1009  bookno -= BMAX[0];
1010  }
1011  curKey->setTestament(t);
1012  curKey->setBook(bookno);
1013  }
1014 
1015  if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
1016  curKey->setChapter(lastKey->getChapter());
1017  curKey->setVerse(chap); // chap because this is the first number captured
1018  if (suffix) {
1019  curKey->setSuffix(suffix);
1020  }
1021  }
1022  else {
1023  if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->getChapterMax() == 1) {
1024  verse = chap;
1025  chap = 1;
1026  }
1027 
1028 
1029  if (chap >= 0) {
1030  curKey->setChapter(chap);
1031  }
1032  else {
1033  partial++;
1034  curKey->setChapter(1);
1035  }
1036  if (verse >= 0) {
1037  curKey->setVerse(verse);
1038  if (suffix) {
1039  curKey->setSuffix(suffix);
1040  }
1041  }
1042  else {
1043  partial++;
1044  curKey->setVerse(1);
1045  }
1046  }
1047 
1048  if ((*buf == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
1049  lastKey->setLowerBound(*curKey);
1050  *lastKey = TOP;
1051  tmpListKey << *lastKey;
1052  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
1053  }
1054  else {
1055  if (!dash) { // if last separator was not a dash just add
1056  if (expandRange && partial) {
1057  lastKey->setLowerBound(*curKey);
1058  if (partial > 1)
1059  *curKey = MAXCHAPTER;
1060  if (partial > 0)
1061  *curKey = MAXVERSE;
1062  lastKey->setUpperBound(*curKey);
1063  *lastKey = TOP;
1064  tmpListKey << *lastKey;
1065  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
1066  }
1067  else {
1068  bool f = false;
1069  if (curKey->getSuffix() == 'f') {
1070  curKey->setSuffix(0);
1071  f = true;
1072  }
1073  lastKey->setLowerBound(*curKey);
1074  if (f && doubleF) (*curKey) = MAXVERSE;
1075  else if (f) (*curKey)++;
1076  lastKey->setUpperBound(*curKey);
1077  *lastKey = TOP;
1078  tmpListKey << *lastKey;
1079  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
1080  }
1081  }
1082  else if (expandRange) {
1083  VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
1084  if (newElement) {
1085  if (partial > 1)
1086  *curKey = MAXCHAPTER;
1087  if (partial > 0)
1088  *curKey = MAXVERSE;
1089  newElement->setUpperBound(*curKey);
1090  *newElement = TOP;
1091  tmpListKey.getElement()->userData = (SW_u64)(bufStart + (buf - iBuf.c_str()));
1092  }
1093  }
1094  }
1095  }
1096  *book = 0;
1097  tmpListKey = TOP;
1098  internalListKey = tmpListKey;
1099  internalListKey = TOP; // Align internalListKey to first element before passing back;
1100 
1101  delete curKey;
1102  delete lastKey;
1103 
1104  return internalListKey;
1105 }
virtual int getChapterMax() const
Definition: versekey.cpp:1327
#define TOP
Definition: swkey.h:68
virtual SWKey * clone() const
Definition: versekey.cpp:278
Definition: swbuf.h:47
virtual const char * getBookName() const
Definition: versekey.cpp:1265
#define MAXVERSE
Definition: versekey.h:43
virtual void setPosition(SW_POSITION newpos)
Definition: versekey.cpp:1288
#define SW_toupper(c)
Definition: utilstr.h:67
virtual void setChapter(int ichapter)
Definition: versekey.cpp:1603
signed char suffix
Definition: versekey.h:99
virtual bool isAutoNormalize() const
Definition: versekey.cpp:1643
signed int verse
Definition: versekey.h:98
virtual void setTestament(char itestament)
Definition: versekey.cpp:1548
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
ListKey internalListKey
Definition: versekey.h:59
virtual char getSuffix() const
Definition: versekey.cpp:1630
virtual int getChapter() const
Definition: versekey.cpp:1522
const char * c_str() const
Definition: swbuf.h:158
virtual int getBookFromAbbrev(const char *abbr) const
Definition: versekey.cpp:396
SWORD_NAMESPACE_START char isRoman(const char *str, int maxchars)
Definition: roman.cpp:31
virtual void setSuffix(char isuffix)
Definition: versekey.cpp:1634
virtual void setVerse(int iverse)
Definition: versekey.cpp:1622
virtual char getBook() const
Definition: versekey.cpp:1510
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
unsigned long long SW_u64
Definition: sysdata.h:56
void clearBounds() const
Definition: versekey.cpp:1202
virtual void setBook(char ibook)
Definition: versekey.cpp:1565
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
int fromRoman(const char *str)
Definition: roman.cpp:39
signed char book
Definition: versekey.h:96
SW_u64 userData
Definition: swkey.h:115
#define MAXCHAPTER
Definition: versekey.h:44
int BMAX[2]
Definition: versekey.h:120
virtual void setAutoNormalize(bool iautonorm)
Definition: versekey.cpp:1648
virtual char getTestament() const
Definition: versekey.cpp:1498
SWDEPRECATED ListKey VerseKey::ParseVerseList ( const char *  buf,
const char *  defaultKey = 0,
bool  expandRange = false,
bool  useChapterAsVerse = false 
)
inline
Deprecated:
Use parseVerseList

Definition at line 453 of file versekey.h.

453 { return parseVerseList(buf, defaultKey, expandRange, useChapterAsVerse); }
virtual ListKey parseVerseList(const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
Definition: versekey.cpp:515
SWDEPRECATED char SWKey::Persist ( ) const
inlineinherited
Deprecated:
Use isPersist

Definition at line 148 of file swkey.h.

148 { return isPersist(); }
bool isPersist() const
Definition: swkey.cpp:99
SWDEPRECATED char SWKey::Persist ( signed char  ipersist)
inlineinherited
Deprecated:
Use setPersist and isPersist instead.

Definition at line 158 of file swkey.h.

158 { setPersist(ipersist!=0); return isPersist(); }
void setPersist(bool ipersist)
Definition: swkey.cpp:135
bool isPersist() const
Definition: swkey.cpp:99
char SWKey::popError ( )
virtualinherited

Gets and clears error status

Returns
error status

Definition at line 147 of file swkey.cpp.

148 {
149  char retval = error;
150 
151  error = 0;
152  return retval;
153 }
char error
Definition: swkey.h:106
void VerseKey::positionFrom ( const SWKey ikey)
virtual

Only repositions this VerseKey to another VerseKey

Reimplemented from SWKey.

Definition at line 183 of file versekey.cpp.

183  {
184  error = 0;
185  const SWKey *fromKey = &ikey;
186  const ListKey *tryList = SWDYNAMIC_CAST(const ListKey, fromKey);
187  if (tryList) {
188  const SWKey *k = tryList->getElement();
189  if (k) fromKey = k;
190  }
191  const VerseKey *tryVerse = SWDYNAMIC_CAST(const VerseKey, fromKey);
192  if (tryVerse) {
193  setFromOther(*tryVerse);
194  }
195  else {
196  SWKey::positionFrom(*fromKey);
197 // extraneous parse which inadvertently clears error flag
198 // SWKey::positionFrom already calls copyFrom which calls setText, which VerseKey::setText already calls parse()
199 // parse();
200  }
201 
202  // should we always perform bounds checks? Tried but seems to cause infinite recursion
203  if (_compare(getUpperBound()) > 0) {
206  }
207  if (_compare(getLowerBound()) < 0) {
210  }
211 }
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
virtual void positionFrom(const SWKey &ikey)
Definition: swkey.h:180
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
virtual int _compare(const VerseKey &ikey)
Definition: versekey.cpp:1790
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
char error
Definition: swkey.h:106
void setFromOther(const VerseKey &vk)
Definition: versekey.cpp:124
Definition: swkey.h:77
void VerseKey::setAutoNormalize ( bool  iautonorm)
virtual

Sets flag that tells VerseKey to automatically normalize itself when modified

Parameters
iautonormvalue which to set autonorm

Definition at line 1648 of file versekey.cpp.

1649 {
1650  autonorm = iautonorm?1:0;
1651  normalize(true);
1652 }
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
char autonorm
Definition: versekey.h:65
void VerseKey::setBook ( char  ibook)
virtual

Sets book

Parameters
ibookvalue which to set book

Definition at line 1565 of file versekey.cpp.

1566 {
1567  suffix = 0;
1568  verse = (intros) ? 0 : 1;
1569  chapter = (intros) ? 0 : 1;
1570  book = ibook;
1571  normalize(true);
1572 }
signed int chapter
Definition: versekey.h:97
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
signed char book
Definition: versekey.h:96
void VerseKey::setBookName ( const char *  bname)
virtual

Definition at line 1582 of file versekey.cpp.

1583 {
1584  int bnum = getBookFromAbbrev(bname);
1585  if (bnum > -1) {
1586  if (bnum > BMAX[0]) {
1587  bnum -= BMAX[0];
1588  testament = 2;
1589  }
1590  else testament = 1;
1591  setBook(bnum);
1592  }
1593  else error = KEYERR_OUTOFBOUNDS;
1594 }
signed char testament
Definition: versekey.h:95
virtual int getBookFromAbbrev(const char *abbr) const
Definition: versekey.cpp:396
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
virtual void setBook(char ibook)
Definition: versekey.cpp:1565
char error
Definition: swkey.h:106
int BMAX[2]
Definition: versekey.h:120
void VerseKey::setChapter ( int  ichapter)
virtual

Sets chapter

Parameters
ichaptervalue which to set chapter

Definition at line 1603 of file versekey.cpp.

1604 {
1605  suffix = 0;
1606  verse = (intros) ? 0 : 1;
1607  chapter = ichapter;
1608  normalize(true);
1609 }
signed int chapter
Definition: versekey.h:97
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
virtual void SWKey::setError ( char  err)
inlinevirtualinherited

Definition at line 165 of file swkey.h.

165 { error = err; }
char error
Definition: swkey.h:106
void VerseKey::setFromOther ( const VerseKey vk)
private

Definition at line 124 of file versekey.cpp.

124  {
125  if (refSys == ikey.refSys) {
126  testament = ikey.getTestament();
127  book = ikey.getBook();
128  chapter = ikey.getChapter();
129  verse = ikey.getVerse();
130  suffix = ikey.getSuffix();
131  }
132  else {
133  // map verse between systems
134  const char* map_book = ikey.getOSISBookName();
135  int map_chapter = ikey.getChapter();
136  int map_verse = ikey.getVerse();
137  int map_range = map_verse;
138 
139  ikey.refSys->translateVerse(refSys, &map_book, &map_chapter, &map_verse, &map_range);
140 //dbg_mapping SWLOGD("verse: %s.%i.%i-%i\n", map_book, map_chapter, map_verse, map_range);
141 
142  book = refSys->getBookNumberByOSISName(map_book);
143 
144  // check existence
145  if (book == -1) {
146  book = 1;
148  }
149  else if (refSys->getBook(book-1)->getChapterMax() < map_chapter) {
150  map_chapter = refSys->getBook(book-1)->getChapterMax();
151  map_verse = refSys->getBook(book-1)->getVerseMax(map_chapter);
153  }
154  else if (map_chapter > 0 && refSys->getBook(book-1)->getVerseMax(map_chapter) < map_verse) {
155  map_verse = refSys->getBook(book-1)->getVerseMax(map_chapter);
157  }
158 
159  // set values
160  if (book > BMAX[0])
161  book -= BMAX[0], testament = 2;
162  else
163  testament = 1;
164 
165  //if (map_verse == 0) Headings(1);
166 
167  chapter = map_chapter;
168  verse = map_verse;
169  suffix = ikey.getSuffix();
170 
171  if (map_verse < map_range) {
172  if (map_range > refSys->getBook(((testament>1)?BMAX[0]:0)+book-1)->getVerseMax(chapter))
173  ++map_range;
174  verse = map_range;
175  setUpperBound(this);
176  verse = map_verse;
177  setLowerBound(this);
178  }
179  }
180 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
signed char suffix
Definition: versekey.h:99
const VersificationMgr::System * refSys
Definition: versekey.h:61
signed int verse
Definition: versekey.h:98
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
const Book * getBook(int number) const
int getBookNumberByOSISName(const char *bookName) const
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
signed char book
Definition: versekey.h:96
char error
Definition: swkey.h:106
int getVerseMax(int chapter) const
int BMAX[2]
Definition: versekey.h:120
void VerseKey::setIndex ( long  iindex)
virtual

Sets index based upon current verse

Parameters
iindexvalue to set index to

Reimplemented from SWKey.

Definition at line 1718 of file versekey.cpp.

1719 {
1720  // assert we're sane
1721  if (iindex < 0) {
1723  return;
1724  }
1725 
1726  int b;
1727  error = refSys->getVerseFromOffset(iindex, &b, &chapter, &verse);
1728  book = (unsigned char)b;
1729  testament = 1;
1730  if (book > BMAX[0]) {
1731  book -= BMAX[0];
1732  testament = 2;
1733  }
1734  // special case for Module and Testament heading
1735  if (book < 0) { testament = 0; book = 0; }
1736  if (chapter < 0) { book = 0; chapter = 0; }
1737 
1738  checkBounds();
1739 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
const VersificationMgr::System * refSys
Definition: versekey.h:61
signed int verse
Definition: versekey.h:98
char getVerseFromOffset(long offset, int *book, int *chapter, int *verse) const
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
signed char book
Definition: versekey.h:96
char error
Definition: swkey.h:106
void checkBounds()
Definition: versekey.cpp:1741
int BMAX[2]
Definition: versekey.h:120
void VerseKey::setIntros ( bool  val)
virtual

The Intros property determine whether or not to include chapter/book/testament/module intros

Definition at line 1663 of file versekey.cpp.

1664 {
1665  intros = val;
1666  normalize(true);
1667 }
char intros
Definition: versekey.h:69
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
void SWKey::setLocale ( const char *  name)
inlineinherited

Definition at line 225 of file swkey.h.

225 { stdstr(&localeName, name); locale = 0; } // this will force an on demand lookup of our locale
char * localeName
Definition: swkey.h:108
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
SWLocale * locale
Definition: swkey.h:94
void VerseKey::setLowerBound ( const VerseKey lb)

sets the lower boundary for this VerseKey

Parameters
lbthe new lower boundary for this VerseKey

Definition at line 1112 of file versekey.cpp.

1113 {
1114  initBounds();
1115 
1116  lowerBound = lb.getIndex();
1122 
1123  // both this following check and UpperBound check force upperBound to
1124  // change allowing LowerBound then UpperBound logic to always flow
1125  // and set values without restrictions, as expected
1127  boundSet = true;
1128 }
VerseComponents lowerBoundComponents
Definition: versekey.h:89
bool boundSet
Definition: swkey.h:104
virtual char getSuffix() const
Definition: versekey.cpp:1630
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
void initBounds() const
Definition: versekey.cpp:1209
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
virtual char getTestament() const
Definition: versekey.cpp:1498
virtual long getIndex() const
Definition: versekey.cpp:1681
void SWKey::setPersist ( bool  ipersist)
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.

Parameters
ipersistvalue which to set persist;

Definition at line 135 of file swkey.cpp.

136 {
137  persist = ipersist;
138 }
bool persist
Definition: swkey.h:105
void VerseKey::setPosition ( SW_POSITION  newpos)
virtual

Positions this key

Parameters
newposPosition to set to.

Reimplemented from SWKey.

Reimplemented in VerseTreeKey.

Definition at line 1288 of file versekey.cpp.

1288  {
1289  switch (p) {
1290  case POS_TOP: {
1291  const VerseKey *lb = &getLowerBound();
1292  testament = (lb->getTestament() || intros) ? lb->getTestament() : 1;
1293  book = (lb->getBook() || intros) ? lb->getBook() : 1;
1294  chapter = (lb->getChapter() || intros) ? lb->getChapter() : 1;
1295  verse = (lb->getVerse() || intros) ? lb->getVerse() : 1;
1296  suffix = lb->getSuffix();
1297  break;
1298  }
1299  case POS_BOTTOM: {
1300  const VerseKey *ub = &getUpperBound();
1301  testament = (ub->getTestament() || intros) ? ub->getTestament() : 1;
1302  book = (ub->getBook() || intros) ? ub->getBook() : 1;
1303  chapter = (ub->getChapter() || intros) ? ub->getChapter() : 1;
1304  verse = (ub->getVerse() || intros) ? ub->getVerse() : 1;
1305  suffix = ub->getSuffix();
1306  break;
1307  }
1308  case POS_MAXVERSE:
1309  suffix = 0;
1310  verse = 1;
1311  normalize();
1312  verse = getVerseMax();
1313  suffix = 0;
1314  break;
1315  case POS_MAXCHAPTER:
1316  suffix = 0;
1317  verse = 1;
1318  chapter = 1;
1319  normalize();
1320  chapter = getChapterMax();
1321  break;
1322  }
1323  normalize(true);
1324  popError(); // clear error from normalize
1325 }
virtual int getChapterMax() const
Definition: versekey.cpp:1327
#define POS_MAXVERSE
Definition: versekey.h:39
signed int chapter
Definition: versekey.h:97
#define POS_MAXCHAPTER
Definition: versekey.h:40
signed char testament
Definition: versekey.h:95
VerseKey & getLowerBound() const
Definition: versekey.cpp:1156
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual char getSuffix() const
Definition: versekey.cpp:1630
virtual int getChapter() const
Definition: versekey.cpp:1522
#define POS_TOP
Definition: swkey.h:65
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
virtual char popError()
Definition: swkey.cpp:147
#define POS_BOTTOM
Definition: swkey.h:66
virtual int getVerseMax() const
Definition: versekey.cpp:1333
signed char book
Definition: versekey.h:96
virtual char getTestament() const
Definition: versekey.cpp:1498
void VerseKey::setSuffix ( char  isuffix)
virtual

Sets/gets verse suffix

Parameters
isuffixvalue which to set verse suffix

Definition at line 1634 of file versekey.cpp.

1634  {
1635  suffix = suf;
1636 }
signed char suffix
Definition: versekey.h:99
void VerseKey::setTestament ( char  itestament)
virtual

Sets testament

Parameters
itestamentvalue which to set testament

Definition at line 1548 of file versekey.cpp.

1549 {
1550  suffix = 0;
1551  verse = (intros) ? 0 : 1;
1552  chapter = (intros) ? 0 : 1;
1553  book = (intros) ? 0 : 1;
1554  testament = itestament;
1555  normalize(true);
1556 }
signed int chapter
Definition: versekey.h:97
signed char testament
Definition: versekey.h:95
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
char intros
Definition: versekey.h:69
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
signed char book
Definition: versekey.h:96
virtual void VerseKey::setText ( const char *  ikey,
bool  checkNormalize 
)
inlinevirtual

Definition at line 220 of file versekey.h.

220 { SWKey::setText(ikey); parse(checkNormalize); }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual char parse(bool checkNormalize=true)
Definition: versekey.cpp:326
virtual void VerseKey::setText ( const char *  ikey)
inlinevirtual

Sets this SWKey with a character string

Parameters
ikeystring used to set this key

Reimplemented from SWKey.

Definition at line 221 of file versekey.h.

221 { SWKey::setText(ikey); parse(); }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual char parse(bool checkNormalize=true)
Definition: versekey.cpp:326
void VerseKey::setUpperBound ( const VerseKey ub)

sets the upper boundary for this VerseKey

Parameters
ubthe new upper boundary for this VerseKey

Definition at line 1135 of file versekey.cpp.

1136 {
1137  initBounds();
1138 
1139  upperBound = ub.getIndex();
1145 
1146  // see setLowerBound comment, above
1148  boundSet = true;
1149 }
bool boundSet
Definition: swkey.h:104
virtual char getSuffix() const
Definition: versekey.cpp:1630
VerseComponents upperBoundComponents
Definition: versekey.h:89
virtual int getChapter() const
Definition: versekey.cpp:1522
virtual char getBook() const
Definition: versekey.cpp:1510
virtual int getVerse() const
Definition: versekey.cpp:1534
void initBounds() const
Definition: versekey.cpp:1209
long lowerBound
Definition: versekey.h:84
long upperBound
Definition: versekey.h:84
virtual char getTestament() const
Definition: versekey.cpp:1498
virtual long getIndex() const
Definition: versekey.cpp:1681
void VerseKey::setVerse ( int  iverse)
virtual

Sets verse

Parameters
iversevalue which to set verse

Definition at line 1622 of file versekey.cpp.

1623 {
1624  suffix = 0;
1625  verse = iverse;
1626  normalize(true);
1627 }
signed char suffix
Definition: versekey.h:99
signed int verse
Definition: versekey.h:98
virtual void normalize(bool autocheck=false)
Definition: versekey.cpp:1401
void VerseKey::setVersificationSystem ( const char *  name)
virtual

Definition at line 298 of file versekey.cpp.

298  {
300  // TODO: cheese, but what should we do if requested v11n system isn't found?
301  if (!newRefSys) newRefSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem("KJV");
302  if (refSys != newRefSys) {
303  refSys = newRefSys;
304  BMAX[0] = refSys->getBMAX()[0];
305  BMAX[1] = refSys->getBMAX()[1];
306 
307  // TODO: adjust bounds for versificaion system ???
308  // TODO: when we have mapping done, rethink this
309  //necessary as our bounds might not mean anything in the new v11n system
310  clearBounds();
311  }
312 
313 }
const VersificationMgr::System * refSys
Definition: versekey.h:61
const int * getBMAX() const
void clearBounds() const
Definition: versekey.cpp:1202
static VersificationMgr * getSystemVersificationMgr()
int BMAX[2]
Definition: versekey.h:120
const System * getVersificationSystem(const char *name) const
SWDEPRECATED char VerseKey::Testament ( ) const
inline
Deprecated:
Use getTestament() instead.

Definition at line 265 of file versekey.h.

265 { return getTestament(); } // deprecated
virtual char getTestament() const
Definition: versekey.cpp:1498
SWDEPRECATED char VerseKey::Testament ( char  itestament)
inline
Deprecated:
Use setTestament() instead.

Definition at line 315 of file versekey.h.

315 { char retVal = getTestament(); setTestament(itestament); return retVal; } // deprecated
virtual void setTestament(char itestament)
Definition: versekey.cpp:1548
virtual char getTestament() const
Definition: versekey.cpp:1498
SWDEPRECATED long VerseKey::TestamentIndex ( ) const
inline
Deprecated:
Use getTestamentIndex()

Definition at line 423 of file versekey.h.

423 { return getTestamentIndex(); } // deprecated, use getTestamentIndex()
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
SWDEPRECATED VerseKey& VerseKey::UpperBound ( const VerseKey ub)
inline
Deprecated:
Use setUpperBound / getUpperBound

Definition at line 182 of file versekey.h.

182 { setUpperBound(ub); return getUpperBound(); }
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
SWDEPRECATED VerseKey& VerseKey::UpperBound ( ) const
inline
Deprecated:
Use getUpperBound

Definition at line 200 of file versekey.h.

200 { return getUpperBound(); }
VerseKey & getUpperBound() const
Definition: versekey.cpp:1179
void VerseKey::validateCurrentLocale ( ) const

Definition at line 473 of file versekey.cpp.

473  {
474  if (SWLog::getSystemLog()->getLogLevel() >= SWLog::LOG_DEBUG) { //make sure log is wanted, this loop stuff costs a lot of time
475  for (int i = 0; i < refSys->getBookCount(); i++) {
477  if (bn != i+1) {
478  char *abbr = 0;
480  strstrip(abbr);
481  SWLog::getSystemLog()->logWarning("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);
482 
484  const bool hasUTF8Support = StringMgr::hasUTF8Support();
485  if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales
486  stringMgr->upperUTF8(abbr, (unsigned int)(strlen(abbr)*2));
487  }
488  else {
489  stringMgr->upperLatin1(abbr);
490  }
491  SWLOGD("%s=%s\n", abbr, refSys->getBook(i)->getOSISName());
492  delete [] abbr;
493  }
494  }
495  }
496 }
static bool hasUTF8Support()
Definition: stringmgr.h:58
static SWLog * getSystemLog()
Definition: swlog.cpp:53
const VersificationMgr::System * refSys
Definition: versekey.h:61
static StringMgr * getSystemStringMgr()
Definition: stringmgr.cpp:197
else preg translate
Definition: regex.c:8111
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const Book * getBook(int number) const
virtual int getBookFromAbbrev(const char *abbr) const
Definition: versekey.cpp:396
virtual char * upperUTF8(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:223
const char * getOSISName() const
SWLocale * getPrivateLocale() const
Definition: swkey.cpp:111
void logWarning(const char *fmt,...) const
Definition: swlog.cpp:74
char * strstrip(char *istr)
Definition: utilstr.cpp:118
virtual char * upperLatin1(char *text, unsigned int max=0) const
Definition: stringmgr.cpp:327
const char * getLongName() const
#define SWLOGD(...)
Definition: defs.h:187
static const char LOG_DEBUG
Definition: swlog.h:46
SWDEPRECATED int VerseKey::Verse ( ) const
inline
Deprecated:
Use getVerse() instead.

Definition at line 298 of file versekey.h.

298 { return getVerse(); } // deprecated
virtual int getVerse() const
Definition: versekey.cpp:1534
SWDEPRECATED int VerseKey::Verse ( int  iverse)
inline
Deprecated:
Use setVerse() instead.

Definition at line 345 of file versekey.h.

345 { char retVal = getVerse(); setVerse(iverse); return retVal; } // deprecated;
virtual void setVerse(int iverse)
Definition: versekey.cpp:1622
virtual int getVerse() const
Definition: versekey.cpp:1534

Member Data Documentation

char VerseKey::autonorm
private

flag for auto normalization

Definition at line 65 of file versekey.h.

int VerseKey::BMAX[2]

Definition at line 120 of file versekey.h.

signed char VerseKey::book
protected

Definition at line 96 of file versekey.h.

bool SWKey::boundSet
mutableprotectedinherited

Definition at line 104 of file swkey.h.

signed int VerseKey::chapter
protected

Definition at line 97 of file versekey.h.

char SWKey::error
mutableprotectedinherited

Definition at line 106 of file swkey.h.

int VerseKey::instance = 0
staticprivate

number of instantiated VerseKey objects or derivitives

Definition at line 58 of file versekey.h.

ListKey VerseKey::internalListKey
private

Definition at line 59 of file versekey.h.

char VerseKey::intros
private

flag for intros on/off

Definition at line 69 of file versekey.h.

char* SWKey::keytext
protectedinherited

Definition at line 102 of file swkey.h.

char* SWKey::localeName
protectedinherited

Definition at line 108 of file swkey.h.

long VerseKey::lowerBound
mutableprivate

Definition at line 84 of file versekey.h.

VerseComponents VerseKey::lowerBoundComponents
mutableprivate

Definition at line 89 of file versekey.h.

const SWClass* SWObject::myClass
protectedinherited

Definition at line 55 of file swobject.h.

bool SWKey::persist
protectedinherited

Definition at line 105 of file swkey.h.

char* SWKey::rangeText
mutableprotectedinherited

Definition at line 103 of file swkey.h.

const VersificationMgr::System* VerseKey::refSys
private

Definition at line 61 of file versekey.h.

signed char VerseKey::suffix
protected

Definition at line 99 of file versekey.h.

signed char VerseKey::testament
protected

The Testament: 0 - Module Heading; 1 - Old; 2 - New

Definition at line 95 of file versekey.h.

VerseKey* VerseKey::tmpClone
mutableprivate

Definition at line 85 of file versekey.h.

long VerseKey::upperBound
mutableprivate

Definition at line 84 of file versekey.h.

VerseComponents VerseKey::upperBoundComponents
mutableprivate

Definition at line 89 of file versekey.h.

SW_u64 SWKey::userData
inherited

Definition at line 115 of file swkey.h.

signed int VerseKey::verse
protected

Definition at line 98 of file versekey.h.


The documentation for this class was generated from the following files: