42 static const char *
classes[] = {
"VerseKey",
"SWKey",
"SWObject", 0};
137 int map_range = map_verse;
171 if (map_verse < map_range) {
185 const SWKey *fromKey = &ikey;
242 const SWKey *fromKey = &ikey;
302 if (
refSys != newRefSys) {
343 if (checkAutoNormalize) {
348 return (this->error) ? this->error : (this->error =
error);
365 sprintf(buf,
"[ Module Heading ]");
366 else sprintf(buf,
"[ Testament %d Heading ]", (
int)
testament);
369 if (realbook >
BMAX[realTest-1]) {
370 realbook -=
BMAX[realTest-1];
373 if (realbook >
BMAX[realTest-1])
374 realbook =
BMAX[realTest-1];
378 buf[strlen(buf)+1] = 0;
379 buf[strlen(buf)] =
suffix;
398 int diff, abLen, min, max, target, retVal = -1;
415 for (
int i = 0; i < 2; i++) {
420 if (hasUTF8Support) {
421 stringMgr->
upperUTF8(abbr, (
unsigned int)(strlen(abbr)*2));
428 abLen = (int)strlen(abbr);
436 target = min + ((max - min) / 2);
437 diff = strncmp(abbr, abbrevs[target].
ab, abLen);
438 if ((!diff)||(target >= max)||(target <= min))
446 for (; target > 0; target--) {
447 if (strncmp(abbr, abbrevs[target-1].
ab, abLen))
454 while ((retVal < 0) && (target < max) && (!strncmp(abbr, abbrevs[target+1].
ab, abLen))) {
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);
485 if (hasUTF8Support) {
486 stringMgr->
upperUTF8(abbr, (
unsigned int)(strlen(abbr)*2));
518 const char *bufStart = buf;
521 SWBuf iDefaultKey = defaultKey;
522 if (defaultKey) defaultKey = iDefaultKey.
c_str();
531 int chap = -1,
verse = -1;
536 const char *orig = buf;
540 char lastPartial = 0;
542 int notAllDigits = 0;
543 bool doubleF =
false;
554 if (!strcmp(buf,
"[ Module Heading ]")) {
561 internalListKey << *lastKey;
566 if ((!strncmp(buf,
"[ Testament ", 12)) &&
567 (isdigit(buf[12])) &&
568 (!strcmp(buf+13,
" Heading ]"))) {
575 internalListKey << *lastKey;
583 if (defaultKey) *lastKey = defaultKey;
589 number[tonumber] = 0;
593 verse = atoi(number);
594 else chap = atoi(number);
600 goto terminate_range;
605 if ((!*number) || (chap < 0))
607 for (q = 1; ((buf[q]) && (buf[q] !=
' ')); q++);
614 if (tobook < 1 || book[tobook-1] !=
' ') {
615 book[tobook++] =
' ';
623 book[tobook+1] = *(buf+1);
635 number[tonumber] = 0;
639 verse = atoi(number);
640 else chap = atoi(number);
647 loop = (int)strlen(book) - 1;
649 for (; loop+1; loop--) {
if (book[loop] ==
' ') book[loop] = 0;
else break; }
651 if (loop > 0 && isdigit(book[loop-1]) && book[loop] >=
'a' && book[loop] <=
'z') {
654 for (; loop+1; loop--) {
655 if ((isdigit(book[loop])) || (book[loop] ==
' ')) {
661 if ((isdigit(book[loop-1])) || (book[loop-1] ==
' ') || (
SW_toupper(book[loop-1]) ==
'F')) {
670 for (loop = (
int)strlen(book) - 1; loop+1; loop--) {
671 if (book[loop] ==
' ') {
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]))) {
692 else if (!
strnicmp(&book[loop+1],
"subscriptio", (
int)strlen(&book[loop+1]))) {
712 if ((bookno > -1) && (suffix ==
'f') && (book[strlen(book)-1] ==
'f')) {
716 if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (
verse >= 0))) {
728 if (bookno >
BMAX[0]) {
737 if (((comma)||((
verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
746 if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->
getChapterMax() == 1) {
772 for (q = 0; ((buf[q]) && (buf[q] ==
' ')); q++);
773 if ((buf[q] ==
'-') && (expandRange)) {
777 tmpListKey << *lastKey;
783 if (expandRange && partial) {
791 tmpListKey << *lastKey;
802 if (f && doubleF) (*curKey) =
MAXVERSE;
803 else if (f) (*curKey)++;
806 tmpListKey << *lastKey;
811 else if (expandRange) {
825 lastPartial = partial;
849 for (notAllDigits = tobook; notAllDigits; notAllDigits--) {
850 if ((!isdigit(book[notAllDigits-1])) && (!strchr(
" .", book[notAllDigits-1])))
853 if (!notAllDigits && !isdigit(buf[1]))
857 number[tonumber] = 0;
861 verse = atoi(number);
862 else chap = atoi(number);
865 else if (chap == -1 && (tobook < 1 || book[tobook-1] !=
' ')) {
866 book[tobook++] =
' ';
873 number[tonumber++] = *buf;
884 if ((*buf >=
'a' && *buf <=
'z' && (chap >=0 || bookno > -1 || lastKey->
isBoundSet()))
887 doubleF = (*buf ==
'f' && suffix ==
'f');
888 if (suffix && !doubleF) {
890 number[tonumber] = 0;
896 number[tonumber] = 0;
903 book[tobook++] = *buf;
907 number[tonumber] = 0;
911 verse = atoi(number);
912 else chap = atoi(number);
918 loop = (int)strlen(book) - 1;
921 for (; loop+1; loop--) {
if (book[loop] ==
' ') book[loop] = 0;
else break; }
925 if (loop > 0 && isdigit(book[loop-1]) && book[loop] >=
'a' && book[loop] <=
'z') {
930 for (; loop+1; loop--) {
931 if ((isdigit(book[loop])) || (book[loop] ==
' ')) {
937 if ((isdigit(book[loop-1])) || (book[loop-1] ==
' ') || (
SW_toupper(book[loop-1]) ==
'F')) {
947 for (loop = (
int)strlen(book) - 1; loop+1; loop--) {
948 if (book[loop] ==
' ') {
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]))) {
969 else if (!
strnicmp(&book[loop+1],
"subscriptio", (
int)strlen(&book[loop+1]))) {
991 if ((bookno > -1) && (suffix ==
'f') && (book[strlen(book)-1] ==
'f')) {
995 if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (
verse >= 0))) {
1007 if (bookno >
BMAX[0]) {
1015 if (((comma)||((
verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
1023 if (useChapterAsVerse && verse < 0 && chap > 0 && curKey->
getChapterMax() == 1) {
1048 if ((*buf ==
'-') && (expandRange)) {
1051 tmpListKey << *lastKey;
1056 if (expandRange && partial) {
1064 tmpListKey << *lastKey;
1074 if (f && doubleF) (*curKey) =
MAXVERSE;
1075 else if (f) (*curKey)++;
1078 tmpListKey << *lastKey;
1082 else if (expandRange) {
1098 internalListKey = tmpListKey;
1099 internalListKey =
TOP;
1249 static char *stext = 0;
1254 sprintf(buf,
"[ Module Heading ]");
1255 else sprintf(buf,
"[ Testament %d Heading ]", (
int)
testament);
1328 if (
book < 1)
return 0;
1334 if (
book < 1)
return 0;
1387 if ((ierror) && (!
intros))
1586 if (bnum >
BMAX[0]) {
1728 book = (
unsigned char)b;
1770 const SWKey *testKey = &ikey;
1775 const VerseKey ivkey = (
const char *)ikey;
1792 unsigned long keyval1 = 0;
1793 unsigned long keyval2 = 0;
1797 keyval1 +=
getBook() * 10000000;
1798 keyval2 += ivkey.
getBook() * 10000000;
1805 keyval1 = (keyval1 != keyval2) ? ((keyval1 > keyval2) ? 1 : -1) : 0;
1806 return (
int)keyval1;
1811 static char buf[5][254];
1812 static int loop = 0;
1823 else buf[loop][0] = 0;
1888 static SWBuf outRef;
1894 const char *startFrag = inRef;
1895 for (
int i = 0; i < verses.
getCount(); i++) {
1903 memset(frag, 0, 800);
1904 memset(preJunk, 0, 800);
1905 memset(postJunk, 0, 800);
1906 while ((*startFrag) && (strchr(
" {}:;,()[].", *startFrag))) {
1907 outRef += *startFrag;
1910 memmove(frag, startFrag, (
size_t)((
const char *)element->
userData - startFrag) + 1);
1911 frag[((
const char *)element->
userData - startFrag) + 1] = 0;
1913 for (j = strlen(frag)-1; j && (strchr(
" {}:;,()[].", frag[j])); j--);
1915 strcpy(postJunk, frag+j+1);
1917 startFrag += ((
const char *)element->
userData - startFrag) + 1;
1918 buf =
"<reference osisRef=\"";
1922 buf +=
"</reference>";
1928 if (startFrag < (inRef + strlen(inRef)))
1929 outRef += startFrag;
1930 return outRef.
c_str();
virtual int getChapterMax() const
virtual void setIndex(long iindex)
virtual bool isBoundSet() const
long getNTStartOffset() const
#define SWORD_NAMESPACE_START
SWBuf & appendFormatted(const char *format,...)
virtual SWKey * clone() const
virtual int getCount() const
virtual const char * getBookName() const
virtual int compare(const SWKey &ikey)
virtual void setPosition(SW_POSITION newpos)
static bool hasUTF8Support()
VerseComponents lowerBoundComponents
virtual bool isIntros() const
long getOffsetFromVerse(int book, int chapter, int verse) const
static SWLog * getSystemLog()
virtual void setBookName(const char *bname)
virtual struct abbrev * getBookAbbrevs(int *retSize)
VerseKey & getLowerBound() const
int getChapterMax() const
virtual void setChapter(int ichapter)
virtual void copyFrom(const SWKey &ikey)
virtual bool isAutoNormalize() const
const VersificationMgr::System * refSys
virtual void positionFrom(const SWKey &ikey)
VerseKey(const char *ikey=0)
virtual void positionFrom(const SWKey &ikey)
static StringMgr * getSystemStringMgr()
virtual void setTestament(char itestament)
int stricmp(const char *s1, const char *s2)
virtual SWKey * getElement(int pos=-1)
virtual const char * getText() const
void setLowerBound(const VerseKey &lb)
static SWORD_NAMESPACE_START const char * classes[]
static const char * convertToOSIS(const char *inRef, const SWKey *defaultKey)
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
virtual int _compare(const VerseKey &ikey)
virtual char getSuffix() const
char getVerseFromOffset(long offset, int *book, int *chapter, int *verse) const
const Book * getBook(int number) const
VerseComponents upperBoundComponents
virtual void setIntros(bool val)
virtual int getChapter() const
const char * c_str() const
virtual char parse(bool checkNormalize=true)
virtual int getBookFromAbbrev(const char *abbr) const
virtual void setVersificationSystem(const char *name)
virtual char * upperUTF8(char *text, unsigned int max=0) const
static const SWClass classdef(classes)
SWORD_NAMESPACE_START char isRoman(const char *str, int maxchars)
virtual void setSuffix(char isuffix)
virtual ListKey parseVerseList(const char *buf, const char *defaultKey=0, bool expandRange=false, bool useChapterAsVerse=false)
virtual void setVerse(int iverse)
virtual const char * getVersificationSystem() const
virtual void copyFrom(const SWKey &ikey)
virtual const char * getShortRangeText() const
virtual const char * getOSISRefRangeText() const
virtual char getBook() const
void translateVerse(const System *dstSys, const char **book, int *chapter, int *verse, int *verse_end) const
virtual void increment(int steps=1)
virtual int getVerse() const
virtual const char * getOSISRef() const
virtual const char * getOSISRefRangeText() const
int getBookNumberByOSISName(const char *bookName) const
VerseKey & getUpperBound() const
#define SWDYNAMIC_CAST(className, object)
void setUpperBound(const VerseKey &ub)
#define KEYERR_OUTOFBOUNDS
const char * getOSISName() const
const char * getPreferredAbbreviation() const
virtual const char * translate(const char *text)
virtual void normalize(bool autocheck=false)
const char * getName() const
SWLocale * getPrivateLocale() const
const int * getBMAX() const
unsigned long long SW_u64
virtual int getVerseMax() const
void logWarning(const char *fmt,...) const
char * strstrip(char *istr)
virtual void setBook(char ibook)
virtual char * upperLatin1(char *text, unsigned int max=0) const
int strnicmp(const char *s1, const char *s2, int len)
int fromRoman(const char *str)
virtual const char * getShortText() const
virtual const char * getRangeText() const
int getVerseMax(int chapter) const
virtual long getTestamentIndex() const
const char * getLongName() const
void setFromOther(const VerseKey &vk)
#define SWORD_NAMESPACE_END
static VersificationMgr * getSystemVersificationMgr()
virtual void setAutoNormalize(bool iautonorm)
virtual const char * getOSISBookName() const
void setLocale(const char *name)
const System * getVersificationSystem(const char *name) const
virtual const char * getBookAbbrev() const
virtual void decrement(int steps=1)
void validateCurrentLocale() const
virtual char getTestament() const
static const char LOG_DEBUG
virtual long getIndex() const