[sword-svn] r2289 - in trunk: include src/modules/comments src/modules/comments/rawcom src/modules/comments/rawcom4 src/modules/comments/zcom src/modules/texts src/modules/texts/rawtext src/modules/texts/rawtext4 src/modules/texts/ztext

scribe at crosswire.org scribe at crosswire.org
Fri Mar 20 10:40:19 MST 2009


Author: scribe
Date: 2009-03-20 10:40:19 -0700 (Fri, 20 Mar 2009)
New Revision: 2289

Modified:
   trunk/include/rawcom.h
   trunk/include/rawcom4.h
   trunk/include/rawtext.h
   trunk/include/rawtext4.h
   trunk/include/swcom.h
   trunk/include/swmodule.h
   trunk/include/swtext.h
   trunk/include/zcom.h
   trunk/include/ztext.h
   trunk/src/modules/comments/rawcom/rawcom.cpp
   trunk/src/modules/comments/rawcom4/rawcom4.cpp
   trunk/src/modules/comments/swcom.cpp
   trunk/src/modules/comments/zcom/zcom.cpp
   trunk/src/modules/texts/rawtext/rawtext.cpp
   trunk/src/modules/texts/rawtext4/rawtext4.cpp
   trunk/src/modules/texts/swtext.cpp
   trunk/src/modules/texts/ztext/ztext.cpp
Log:
Applying Ben Morgan's patch to add isLinked logic to SWModule


Modified: trunk/include/rawcom.h
===================================================================
--- trunk/include/rawcom.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/rawcom.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -54,6 +54,9 @@
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
+
+
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/include/rawcom4.h
===================================================================
--- trunk/include/rawcom4.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/rawcom4.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -54,6 +54,8 @@
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
+	
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/include/rawtext.h
===================================================================
--- trunk/include/rawtext.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/rawtext.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -49,6 +49,9 @@
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
+	
+
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/include/rawtext4.h
===================================================================
--- trunk/include/rawtext4.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/rawtext4.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -50,6 +50,8 @@
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
+
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/include/swcom.h
===================================================================
--- trunk/include/swcom.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/swcom.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -40,7 +40,7 @@
 	char *versification;
 
 protected:
-	VerseKey &getVerseKey() const;
+	VerseKey &getVerseKey(const SWKey *key = 0) const;
 
 
 public:

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/swmodule.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -639,6 +639,8 @@
 	 *	consecutive links when iterating
 	 */
 	virtual bool getSkipConsecutiveLinks() { return skipConsecutiveLinks; }
+	
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const { return false; }
 
 	/** Entry Attributes are special data pertaining to the current entry.
 	 *	To see what Entry Attributes exists for a specific entry of a module,

Modified: trunk/include/swtext.h
===================================================================
--- trunk/include/swtext.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/swtext.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -40,7 +40,7 @@
 	char *versification;
 
 protected:
-	VerseKey &getVerseKey() const;
+	VerseKey &getVerseKey(const SWKey* key=0) const;
 	
 public:
 	/** Initializes data for instance of SWText

Modified: trunk/include/zcom.h
===================================================================
--- trunk/include/zcom.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/zcom.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -65,6 +65,8 @@
 	virtual void flush() { flushCache(); }
 	// end swcacher interface ----------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
+	
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/include/ztext.h
===================================================================
--- trunk/include/ztext.h	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/include/ztext.h	2009-03-20 17:40:19 UTC (rev 2289)
@@ -81,6 +81,7 @@
 	virtual void flush() { flushCache(); }
 	// end swcacher interface ----------------------
 
+	virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
 	SWMODULE_OPERATORS
 
 };

Modified: trunk/src/modules/comments/rawcom/rawcom.cpp
===================================================================
--- trunk/src/modules/comments/rawcom/rawcom.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/comments/rawcom/rawcom.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -165,5 +165,18 @@
 	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;
+}
+
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/comments/rawcom4/rawcom4.cpp
===================================================================
--- trunk/src/modules/comments/rawcom4/rawcom4.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/comments/rawcom4/rawcom4.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -164,5 +164,18 @@
 	doSetText(key->Testament(), key->TestamentIndex(), "");
 }
 
+bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
+	long start1, start2;
+	unsigned long 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;
+}
+
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/comments/swcom.cpp
===================================================================
--- trunk/src/modules/comments/swcom.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/comments/swcom.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -103,17 +103,19 @@
 }
 
 
-VerseKey &SWCom::getVerseKey() const {
+VerseKey &SWCom::getVerseKey(const SWKey *keyToConvert) const {
+	const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
+
 	VerseKey *key = 0;
 	// see if we have a VerseKey * or decendant
 	SWTRY {
-		key = SWDYNAMIC_CAST(VerseKey, this->key);
+		key = SWDYNAMIC_CAST(VerseKey, thisKey);
 	}
 	SWCATCH ( ... ) {	}
 	if (!key) {
 		ListKey *lkTest = 0;
 		SWTRY {
-			lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+			lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
 		}
 		SWCATCH ( ... ) {	}
 		if (lkTest) {
@@ -125,7 +127,7 @@
 	}
 	if (!key) {
 		tmpVK->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
-		(*tmpVK) = *(this->key);
+		(*tmpVK) = *(thisKey);
 		return (*tmpVK);
 	}
 	else	return *key;

Modified: trunk/src/modules/comments/zcom/zcom.cpp
===================================================================
--- trunk/src/modules/comments/zcom/zcom.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/comments/zcom/zcom.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -199,5 +199,18 @@
 	error = (error) ? KEYERR_OUTOFBOUNDS : 0;
 }
 
+bool zCom::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;
+}
+
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/texts/rawtext/rawtext.cpp
===================================================================
--- trunk/src/modules/texts/rawtext/rawtext.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/texts/rawtext/rawtext.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -182,4 +182,19 @@
 	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;
+
+	findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
+	findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+	if (!size1 || !size2) return false;
+	return start1 == start2;
+}
+
+	
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/texts/rawtext4/rawtext4.cpp
===================================================================
--- trunk/src/modules/texts/rawtext4/rawtext4.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/texts/rawtext4/rawtext4.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -182,4 +182,16 @@
 	error = (error) ? KEYERR_OUTOFBOUNDS : 0;
 }
 
+bool RawText4::isLinked(const SWKey *k1, const SWKey *k2) const {
+	long start1, start2;
+	unsigned long 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);
+	return start1 == start2;
+}
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/texts/swtext.cpp
===================================================================
--- trunk/src/modules/texts/swtext.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/texts/swtext.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -105,17 +105,19 @@
 }
 
 
-VerseKey &SWText::getVerseKey() const {
+VerseKey &SWText::getVerseKey(const SWKey *keyToConvert) const {
+	const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
+
 	VerseKey *key = 0;
 	// see if we have a VerseKey * or decendant
 	SWTRY {
-		key = SWDYNAMIC_CAST(VerseKey, this->key);
+		key = SWDYNAMIC_CAST(VerseKey, thisKey);
 	}
 	SWCATCH ( ... ) {	}
 	if (!key) {
 		ListKey *lkTest = 0;
 		SWTRY {
-			lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+			lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
 		}
 		SWCATCH ( ... ) {	}
 		if (lkTest) {
@@ -127,7 +129,7 @@
 	}
 	if (!key) {
 		tmpVK->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
-		(*tmpVK) = *(this->key);
+		(*tmpVK) = *(thisKey);
 		return (*tmpVK);
 	}
 	else	return *key;

Modified: trunk/src/modules/texts/ztext/ztext.cpp
===================================================================
--- trunk/src/modules/texts/ztext/ztext.cpp	2009-03-20 17:27:29 UTC (rev 2288)
+++ trunk/src/modules/texts/ztext/ztext.cpp	2009-03-20 17:40:19 UTC (rev 2289)
@@ -205,6 +205,16 @@
 	error = (error) ? KEYERR_OUTOFBOUNDS : 0;
 }
 
+bool zText::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);
+	return start1 == start2;
+}
 
 SWORD_NAMESPACE_END




More information about the sword-cvs mailing list