[sword-svn] r2176 - in trunk: . include src/keys src/modules/genbook/rawgenbook

scribe at www.crosswire.org scribe at www.crosswire.org
Sat Jun 14 20:07:25 MST 2008


Author: scribe
Date: 2008-06-14 20:07:24 -0700 (Sat, 14 Jun 2008)
New Revision: 2176

Modified:
   trunk/include/versekey.h
   trunk/include/versetreekey.h
   trunk/src/keys/versekey.cpp
   trunk/src/keys/versetreekey.cpp
   trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp
   trunk/usrinst.sh
Log:
Basic working infrastructure for versetreekey.
Adding KeyType=VerseKey to lxxm.conf will now allow
sword/examples/cmdline/lookup LXXM "Genesis 1:1"
But no dynamic versification yet.  


Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/include/versekey.h	2008-06-15 03:07:24 UTC (rev 2176)
@@ -396,6 +396,7 @@
 	virtual long Index(long iindex);
 
 	virtual const char *getOSISRef() const;
+	virtual const char *getOSISBookName() const;
 	static const int getOSISBookNum(const char *bookab);
 
 	/** Tries to parse a string and convert it into an OSIS reference

Modified: trunk/include/versetreekey.h
===================================================================
--- trunk/include/versetreekey.h	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/include/versetreekey.h	2008-06-15 03:07:24 UTC (rev 2176)
@@ -41,6 +41,9 @@
 	static SWClass classdef;
 	TreeKey *treeKey;
 
+	void init(TreeKey *treeKey);
+	void syncVerseToTree();
+
 public:
 
 	/**
@@ -74,6 +77,7 @@
 	*/
 	VerseTreeKey(const VerseTreeKey &k);
 	
+
 	/**	VerseKey Destructor
 	* Cleans up an instance of VerseKey
 	*/
@@ -86,9 +90,8 @@
 	
 	virtual bool isTraversable() const { return true; }
 
-	virtual TreeKey *getTreeKey() { return treeKey; }
+	virtual TreeKey *getTreeKey();
 	
-
 	// OPERATORS --------------------------------------------------------------------
 
 

Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/src/keys/versekey.cpp	2008-06-15 03:07:24 UTC (rev 2176)
@@ -1556,6 +1556,11 @@
 const char **VerseKey::osisbooks[] = { osisotbooks, osisntbooks };
 
 
+const char *VerseKey::getOSISBookName() const {
+		return osisbooks[Testament()-1][Book()-1];
+}
+
+
 const char *VerseKey::getOSISRef() const {
 	static char buf[5][254];
 	static int loop = 0;

Modified: trunk/src/keys/versetreekey.cpp
===================================================================
--- trunk/src/keys/versetreekey.cpp	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/src/keys/versetreekey.cpp	2008-06-15 03:07:24 UTC (rev 2176)
@@ -20,7 +20,7 @@
 
 VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const SWKey *ikey) : VerseKey(ikey)
 {
-	this->treeKey = treeKey;
+	init(treeKey);
 	if (ikey)
 		parse();
 }
@@ -35,7 +35,7 @@
 
 VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const char *ikey) : VerseKey(ikey)
 {
-	this->treeKey = treeKey;
+	init(treeKey);
 	if (ikey)
 		parse();
 }
@@ -43,13 +43,20 @@
 
 VerseTreeKey::VerseTreeKey(VerseTreeKey const &k) : VerseKey(k)
 {
-	treeKey = k.treeKey;
+	init(k.treeKey);
 }
 
 
 VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const char *min, const char *max) : VerseKey(min, max)
 {
+	init(treeKey);
+}
+
+
+void VerseTreeKey::init(TreeKey *treeKey)
+{
 	this->treeKey = treeKey;
+	myclass = &classdef;
 }
 
 
@@ -68,5 +75,17 @@
 VerseTreeKey::~VerseTreeKey() {
 }
 
+void VerseTreeKey::syncVerseToTree() {
+	SWBuf path;
+	path.setFormatted("/%s/%d/%d", getOSISBookName(), Chapter(), Verse());
+	treeKey->setText(path);
+}
 
+
+TreeKey *VerseTreeKey::getTreeKey() {
+	syncVerseToTree();
+	return treeKey;
+}
+
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp
===================================================================
--- trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp	2008-06-15 03:07:24 UTC (rev 2176)
@@ -81,6 +81,7 @@
 
 	__u32 offset = 0;
 	__u32 size = 0;
+	bool freeKey = false;
 
 	TreeKey *key = 0;
 	SWTRY {
@@ -98,6 +99,7 @@
 	}
 
 	if (!key) {
+		freeKey = true;
 		key = (TreeKeyIdx *)CreateKey();
 		(*key) = *(this->key);
 	}
@@ -126,7 +128,7 @@
 			RawStr::prepText(entryBuf);
 	}
 
-	if (key != this->key) // free our key if we created a VerseKey
+	if (freeKey) // free our key if we created a VerseKey
 		delete key;
 
 	return entryBuf;
@@ -212,8 +214,9 @@
 
 
 SWKey *RawGenBook::CreateKey() {
-	TreeKeyIdx *newKey = new TreeKeyIdx(path);
-	return (verseKey) ? (SWKey *)new VerseTreeKey(newKey) : newKey;
+	SWKey *newKey = new TreeKeyIdx(path);
+	if (verseKey) newKey = new VerseTreeKey((TreeKeyIdx *)newKey);
+	return newKey;
 }
 
 SWORD_NAMESPACE_END

Modified: trunk/usrinst.sh
===================================================================
--- trunk/usrinst.sh	2008-05-20 07:23:53 UTC (rev 2175)
+++ trunk/usrinst.sh	2008-06-15 03:07:24 UTC (rev 2176)
@@ -7,12 +7,12 @@
 #OPTIONS="--with-vcl $OPTIONS"
 OPTIONS="--enable-debug $OPTIONS"
 #OPTIONS="--enable-profile $OPTIONS"
-OPTIONS="--with-icu $OPTIONS"
+#OPTIONS="--with-icu $OPTIONS"
 #OPTIONS="--without-clucene $OPTIONS"
 #OPTIONS="--without-curl $OPTIONS"
-OPTIONS="--enable-tests $OPTIONS"
-#OPTIONS="--disable-utilities $OPTIONS"
-#OPTIONS="--libdir=/usr/lib64 $OPTIONS"
+#OPTIONS="--enable-tests $OPTIONS"
+OPTIONS="--disable-utilities $OPTIONS"
+OPTIONS="--libdir=/usr/lib64 $OPTIONS"
 
 
 CPPFLAGS="$CFLAGS $CPPFLAGS -DUSBINARY" ./configure $OPTIONS $*




More information about the sword-cvs mailing list