summaryrefslogtreecommitdiff
path: root/src/modules/texts
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
commit7a00574163029c0c2b649878c95d5acbd083564a (patch)
treec13cc5736025834df2874ed87ee8598070025ea6 /src/modules/texts
parentb745315323de9f27538edac9453205ca70e6186e (diff)
Imported Upstream version 1.7.2+dfsg
Diffstat (limited to 'src/modules/texts')
-rw-r--r--src/modules/texts/rawtext/rawtext.cpp49
-rw-r--r--src/modules/texts/rawtext4/Makefile5
-rw-r--r--src/modules/texts/rawtext4/rawtext4.cpp54
-rw-r--r--src/modules/texts/swtext.cpp31
-rw-r--r--src/modules/texts/ztext/ztext.cpp59
5 files changed, 100 insertions, 98 deletions
diff --git a/src/modules/texts/rawtext/rawtext.cpp b/src/modules/texts/rawtext/rawtext.cpp
index 8641a45..4fb716c 100644
--- a/src/modules/texts/rawtext/rawtext.cpp
+++ b/src/modules/texts/rawtext/rawtext.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext.cpp - code for class 'RawText'- a module that reads raw text files:
- * ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawtext.cpp - code for class 'RawText'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawtext.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -71,7 +73,7 @@ RawText::~RawText() {
}
-bool RawText::isWritable() {
+bool RawText::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -83,16 +85,16 @@ bool RawText::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawText::getRawEntryBuf() {
+SWBuf &RawText::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key.Testament(), start, size, entryBuf);
+ readText(key.getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, &key);
@@ -106,14 +108,14 @@ SWBuf &RawText::getRawEntryBuf() {
void RawText::setEntry(const char *inbuf, long len) {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
}
void RawText::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -125,7 +127,7 @@ void RawText::linkEntry(const SWKey *inkey) {
void RawText::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
/******************************************************************************
@@ -141,7 +143,7 @@ void RawText::increment(int steps) {
unsigned short size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -151,17 +153,21 @@ void RawText::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
+
if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
+ (
+ ((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ && (size) // and we actually have a size
+ )
+ || !skipConsecutiveLinks
+ ) { // or we don't want to skip consecutive links
steps += (steps < 0) ? 1 : -1;
lastgood = *tmpkey;
}
@@ -169,15 +175,16 @@ void RawText::increment(int steps) {
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
}
+
bool RawText::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;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -187,7 +194,7 @@ bool RawText::hasEntry(const SWKey *k) const {
unsigned short size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/texts/rawtext4/Makefile b/src/modules/texts/rawtext4/Makefile
new file mode 100644
index 0000000..a08e07e
--- /dev/null
+++ b/src/modules/texts/rawtext4/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/texts/rawtext4/rawtext4.cpp b/src/modules/texts/rawtext4/rawtext4.cpp
index 65f5cef..5980801 100644
--- a/src/modules/texts/rawtext4/rawtext4.cpp
+++ b/src/modules/texts/rawtext4/rawtext4.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext4.cpp - code for class 'RawText4'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawtext4.cpp - code for class 'RawText4'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawtext4.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -31,24 +33,8 @@
#include <versekey.h>
#include <stringmgr.h>
-#include <regex.h> // GNU
-#include <map>
-#include <list>
-#include <algorithm>
-
-#ifndef USELUCENE
-using std::map;
-using std::list;
-using std::find;
-#endif
-
SWORD_NAMESPACE_START
-#ifndef USELUCENE
-typedef map < SWBuf, list<long> > strlist;
-typedef list<long> longlist;
-#endif
-
/******************************************************************************
* RawText4 Constructor - Initializes data for instance of RawText4
*
@@ -71,7 +57,7 @@ RawText4::~RawText4() {
}
-bool RawText4::isWritable() {
+bool RawText4::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -83,16 +69,16 @@ bool RawText4::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawText4::getRawEntryBuf() {
+SWBuf &RawText4::getRawEntryBuf() const {
long start = 0;
unsigned long size = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key.Testament(), start, size, entryBuf);
+ readText(key.getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, &key);
@@ -106,14 +92,14 @@ SWBuf &RawText4::getRawEntryBuf() {
void RawText4::setEntry(const char *inbuf, long len) {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
}
void RawText4::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -125,7 +111,7 @@ void RawText4::linkEntry(const SWKey *inkey) {
void RawText4::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
/******************************************************************************
@@ -141,7 +127,7 @@ void RawText4::increment(int steps) {
unsigned long size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -151,12 +137,12 @@ void RawText4::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -174,10 +160,10 @@ bool RawText4::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
return start1 == start2;
}
@@ -186,7 +172,7 @@ bool RawText4::hasEntry(const SWKey *k) const {
unsigned long size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/texts/swtext.cpp b/src/modules/texts/swtext.cpp
index a7f5f92..9c3c02d 100644
--- a/src/modules/texts/swtext.cpp
+++ b/src/modules/texts/swtext.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
- * swtext.cpp - code for base class 'SWText'- The basis for all text modules
*
+ * swtext.cpp - code for base class 'SWText'- The basis for all text
+ * modules
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swtext.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -38,9 +41,9 @@ SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWT
this->versification = 0;
stdstr(&(this->versification), versification);
delete key;
- key = (VerseKey *)CreateKey();
- tmpVK1 = (VerseKey *)CreateKey();
- tmpVK2 = (VerseKey *)CreateKey();
+ key = (VerseKey *)createKey();
+ tmpVK1 = (VerseKey *)createKey();
+ tmpVK2 = (VerseKey *)createKey();
tmpSecond = false;
skipConsecutiveLinks = false;
}
@@ -58,10 +61,10 @@ SWText::~SWText() {
/******************************************************************************
- * SWText CreateKey - Create the correct key (VerseKey) for use with SWText
+ * SWText createKey - Create the correct key (VerseKey) for use with SWText
*/
-SWKey *SWText::CreateKey() const {
+SWKey *SWText::createKey() const {
VerseKey *vk = new VerseKey();
vk->setVersificationSystem(versification);
@@ -70,24 +73,22 @@ SWKey *SWText::CreateKey() const {
}
-long SWText::Index() const {
+long SWText::getIndex() const {
VerseKey *key = &getVerseKey();
- entryIndex = key->Index();
+ entryIndex = key->getIndex();
return entryIndex;
}
-long SWText::Index(long iindex) {
+void SWText::setIndex(long iindex) {
VerseKey *key = &getVerseKey();
- key->Testament(1);
- key->Index(iindex);
+ key->setTestament(1);
+ key->setIndex(iindex);
if (key != this->key) {
this->key->copyFrom(*key);
}
-
- return Index();
}
@@ -108,7 +109,7 @@ VerseKey &SWText::getVerseKey(const SWKey *keyToConvert) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
diff --git a/src/modules/texts/ztext/ztext.cpp b/src/modules/texts/ztext/ztext.cpp
index 61b3008..f0afe6d 100644
--- a/src/modules/texts/ztext/ztext.cpp
+++ b/src/modules/texts/ztext/ztext.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * ztext.cpp - code for class 'zText'- a module that reads compressed text
- * files: ot and nt using indexs ??.vss
*
+ * ztext.cpp - code for class 'zText'- a module that reads compressed text
+ * files
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: ztext.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,9 +30,6 @@
#include <ztext.h>
-#include <regex.h> // GNU
-
-
SWORD_NAMESPACE_START
/******************************************************************************
@@ -65,7 +64,7 @@ zText::~zText()
}
-bool zText::isWritable() { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR)); }
+bool zText::isWritable() const { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR)); }
/******************************************************************************
@@ -74,18 +73,18 @@ bool zText::isWritable() { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode &
* RET: buffer with verse
*/
-SWBuf &zText::getRawEntryBuf() {
+SWBuf &zText::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
unsigned long buffnum = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size, &buffnum);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size, &buffnum);
entrySize = size; // support getEntrySize call
entryBuf = "";
- zReadText(key.Testament(), start, size, buffnum, entryBuf);
+ zReadText(key.getTestament(), start, size, buffnum, entryBuf);
rawFilter(entryBuf, &key);
// if (!isUnicode())
@@ -96,18 +95,18 @@ SWBuf &zText::getRawEntryBuf() {
bool zText::sameBlock(VerseKey *k1, VerseKey *k2) {
- if (k1->Testament() != k2->Testament())
+ if (k1->getTestament() != k2->getTestament())
return false;
switch (blockType) {
case VERSEBLOCKS:
- if (k1->Verse() != k2->Verse())
+ if (k1->getVerse() != k2->getVerse())
return false;
case CHAPTERBLOCKS:
- if (k1->Chapter() != k2->Chapter())
+ if (k1->getChapter() != k2->getChapter())
return false;
case BOOKBLOCKS:
- if (k1->Book() != k2->Book())
+ if (k1->getBook() != k2->getBook())
return false;
}
return true;
@@ -125,7 +124,7 @@ void zText::setEntry(const char *inbuf, long len) {
delete lastWriteKey;
}
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
lastWriteKey = (VerseKey *)key.clone(); // must delete
}
@@ -134,7 +133,7 @@ void zText::setEntry(const char *inbuf, long len) {
void zText::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -147,7 +146,7 @@ void zText::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
@@ -164,7 +163,7 @@ void zText::increment(int steps) {
unsigned long buffnum;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -174,18 +173,21 @@ void zText::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size, &buffnum);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
+ (
+ ((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ && (size) // and we actually have a size
+ )
+ || !skipConsecutiveLinks
+ ) { // or we don't want to skip consecutive links
steps += (steps < 0) ? 1 : -1;
lastgood = *tmpkey;
}
@@ -193,16 +195,17 @@ void zText::increment(int steps) {
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
}
+
bool zText::isLinked(const SWKey *k1, const SWKey *k2) const {
long start1, start2;
unsigned short size1, size2;
unsigned long buffnum1, buffnum2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1, &buffnum1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2, &buffnum2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
return start1 == start2 && buffnum1 == buffnum2;
}
@@ -212,7 +215,7 @@ bool zText::hasEntry(const SWKey *k) const {
unsigned long buffnum;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
return size;
}