summaryrefslogtreecommitdiff
path: root/src/modules/comments/rawcom/rawcom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/comments/rawcom/rawcom.cpp')
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
index fd01c24..c0404ae 100644
--- a/src/modules/comments/rawcom/rawcom.cpp
+++ b/src/modules/comments/rawcom/rawcom.cpp
@@ -1,6 +1,22 @@
/******************************************************************************
* rawcom.cpp - code for class 'RawCom'- a module that reads raw commentary
* files: ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ *
+ * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
*/
@@ -23,9 +39,9 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-RawCom::RawCom(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, const char* ilang)
+RawCom::RawCom(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, const char *ilang, const char *versification)
: RawVerse(ipath),
- SWCom(iname, idesc, idisp, encoding, dir, markup, ilang){
+ SWCom(iname, idesc, idisp, encoding, dir, markup, ilang, versification) {
}
@@ -53,7 +69,7 @@ SWBuf &RawCom::getRawEntryBuf() {
unsigned short size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->Index(), &start, &size);
+ findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
@@ -82,21 +98,21 @@ void RawCom::increment(int steps) {
unsigned short size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
+ findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
long laststart = start;
unsigned short lastsize = size;
SWKey lasttry = *tmpkey;
- (steps > 0) ? (*key)++ : (*key)--;
+ (steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
if ((error = key->Error())) {
*key = lastgood;
break;
}
- long index = tmpkey->Index();
+ long index = tmpkey->TestamentIndex();
findOffset(tmpkey->Testament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
@@ -113,24 +129,15 @@ void RawCom::increment(int steps) {
void RawCom::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->Index(), inbuf, len);
+ doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
}
void RawCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
- const VerseKey *srckey = 0;
-
- // see if we have a VerseKey * or decendant
- SWTRY {
- srckey = SWDYNAMIC_CAST(VerseKey, inkey);
- }
- SWCATCH ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!srckey)
- srckey = new VerseKey(inkey);
+ const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->Index(), srckey->Index());
+ doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -146,8 +153,29 @@ void RawCom::linkEntry(const SWKey *inkey) {
void RawCom::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->Index(), "");
+ doSetText(key->Testament(), key->TestamentIndex(), "");
+}
+
+bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
+ long start1, start2;
+ unsigned short size1, size2;
+ VerseKey *vk1 = &getVerseKey(k1);
+ VerseKey *vk2 = &getVerseKey(k2);
+ if (vk1->Testament() != vk2->Testament()) return false;
+
+ findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
+ findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ if (!size1 || !size2) return false;
+ return start1 == start2;
}
+bool RawCom::hasEntry(const SWKey *k) const {
+ long start;
+ unsigned short size;
+ VerseKey *vk = &getVerseKey(k);
+
+ findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ return size;
+}
SWORD_NAMESPACE_END