[sword-svn] r1917 - in trunk: . bindings/corba/orbitcpp include src/keys src/mgr src/modules/filters src/modules/genbook/rawgenbook

scribe at crosswire.org scribe at crosswire.org
Sun May 21 18:07:26 MST 2006


Author: scribe
Date: 2006-05-21 18:07:17 -0700 (Sun, 21 May 2006)
New Revision: 1917

Added:
   trunk/include/versetreekey.h
   trunk/src/keys/versetreekey.cpp
Modified:
   trunk/ChangeLog
   trunk/bindings/corba/orbitcpp/testclient.cpp
   trunk/bindings/corba/orbitcpp/webmgr.hpp
   trunk/include/Makefile.am
   trunk/include/rawgenbook.h
   trunk/include/swbuf.h
   trunk/include/versekey.h
   trunk/src/keys/Makefile.am
   trunk/src/mgr/swmgr.cpp
   trunk/src/modules/filters/gbfstrongs.cpp
   trunk/src/modules/filters/osisstrongs.cpp
   trunk/src/modules/filters/osiswebif.cpp
   trunk/src/modules/filters/osiswordjs.cpp
   trunk/src/modules/filters/thmlstrongs.cpp
   trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp
   trunk/usrinst.sh
Log:
	Added SWBuf::startsWith, endsWith
	Added entry attribute exposure of multipart words
	Added beginnings of VerseKey subclass which uses TreeKey



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/ChangeLog	2006-05-22 01:07:17 UTC (rev 1917)
@@ -1,6 +1,11 @@
 API ChangeLog	(see the ChangeLog in each 'apps' directory for
 		app specific changes)
 
+21-May-2006	Troy A. Griffitts <scribe at crosswire.org>
+	Added SWBuf::startsWith, endsWith
+	Added entry attribute exposure of multipart words
+	Added beginnings of VerseKey subclass which uses TreeKey
+	
 25-Apr-2006	Troy A. Griffitts <scribe at crosswire.org>
 	Changed SWModule::search to fill result set up with more
 		specialized SWKey objects, instead of always SWKey

Modified: trunk/bindings/corba/orbitcpp/testclient.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/testclient.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/bindings/corba/orbitcpp/testclient.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -52,7 +52,7 @@
 		mgr->setJavascript(true);
 		mgr->setGlobalOption("Textual Variants", "Secondary Reading");
 		mgr->setGlobalOption("Footnotes", "On");
-		module = mgr->getModuleByName("WEB");
+		module = mgr->getModuleByName("KJV2006");
 /*
 		module->setKeyText("jas.1.19");
 		swordorb::StringList *attr = module->getEntryAttribute("Footnote", "", "body", true);
@@ -62,9 +62,10 @@
 		}
 */
 		int i = 0;
-		for (module->setKeyText("jas.1.1"); !module->error() && i < 30; module->next(), i++) {
+		for (module->setKeyText("jas.2.14"); !module->error() && i < 30; module->next(), i++) {
 			std::cout << "KeyText: " << module->getKeyText() << "\n";
 			std::cout << "Text: " << module->getRenderText() << "\n";
+			break;
 		}
 /*
 		swordorb::SearchHitList *searchResults;

Modified: trunk/bindings/corba/orbitcpp/webmgr.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/webmgr.hpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/bindings/corba/orbitcpp/webmgr.hpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -48,6 +48,8 @@
 
 
 	void AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
+		SWMgr::AddGlobalOptions(module, section, start, end);
+
 		if (module->getConfig().has("Feature", "GreekDef")) {
 			defaultGreekLex = module;
 		}
@@ -76,7 +78,6 @@
 		if (module->Markup() == FMT_GBF) {
 			module->AddOptionFilter(gbfWordJS);
 		}
-		SWMgr::AddGlobalOptions(module, section, start, end);
 	}
 
 

Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/include/Makefile.am	2006-05-22 01:07:17 UTC (rev 1917)
@@ -143,6 +143,7 @@
 pkginclude_HEADERS += $(swincludedir)/utilxml.h
 
 pkginclude_HEADERS += $(swincludedir)/versekey.h
+pkginclude_HEADERS += $(swincludedir)/versetreekey.h
 pkginclude_HEADERS += $(swincludedir)/zcom.h
 pkginclude_HEADERS += $(swincludedir)/zconf.h
 pkginclude_HEADERS += $(swincludedir)/zipcomprs.h

Modified: trunk/include/rawgenbook.h
===================================================================
--- trunk/include/rawgenbook.h	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/include/rawgenbook.h	2006-05-22 01:07:17 UTC (rev 1917)
@@ -34,6 +34,7 @@
 class SWDLLEXPORT RawGenBook : public SWGenBook {
 	char *path;
 	FileDesc *bdtfd;
+	bool verseKey;
 
 public:
   
@@ -41,7 +42,7 @@
 	RawGenBook(const char *ipath, const char *iname = 0, const char *idesc = 0,
 			SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR,
-			SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
+			SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0, const char *keyType = "TreeKey");
 	virtual ~RawGenBook();
 	virtual SWBuf &getRawEntryBuf();
 	// write interface ----------------------------

Modified: trunk/include/swbuf.h
===================================================================
--- trunk/include/swbuf.h	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/include/swbuf.h	2006-05-22 01:07:17 UTC (rev 1917)
@@ -320,6 +320,8 @@
 	}
 	inline SWBuf operator +(char ch) const { return (*this) + SWBuf(ch); }
 
+	inline bool startsWith(const SWBuf &prefix) const { return !strncmp(c_str(), prefix.c_str(), prefix.size()); }
+	inline bool endsWith(const SWBuf &postfix) const { return (size() >= postfix.size())?!strncmp(end-postfix.size(), postfix.c_str(), postfix.size()):false; }
 	inline int compare(const SWBuf &other) const { return strcmp(c_str(), other.c_str()); }
 	inline bool operator ==(const SWBuf &other) const { return !compare(other); }
 	inline bool operator !=(const SWBuf &other) const { return compare(other); }
@@ -328,7 +330,9 @@
 	inline bool operator <=(const SWBuf &other) const { return compare(other) <= 0; }
 	inline bool operator >=(const SWBuf &other) const { return compare(other) >= 0; }
 
-	inline int compare(const char* other) const { return strcmp(c_str(), other); }
+	inline bool startsWith(const char *prefix) const { return !strncmp(c_str(), prefix, strlen(prefix)); }
+	inline bool endsWith(const char *postfix) const { int psize = strlen(postfix); return (size() >= psize)?!strncmp(end-psize, postfix, psize):false; }
+	inline int compare(const char *other) const { return strcmp(c_str(), other); }
 	inline bool operator ==(const char *other) const { return !compare(other); }
 	inline bool operator !=(const char *other) const { return compare(other); }
 	inline bool operator > (const char *other) const { return compare(other) > 0; }

Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/include/versekey.h	2006-05-22 01:07:17 UTC (rev 1917)
@@ -114,36 +114,33 @@
 	const struct abbrev *abbrevs;
 	char *locale;
 	int abbrevsCnt;
+
 	/** The Testament: 0 - Old; 1 - New
 	*/
 	signed char testament;
 	mutable signed char book;
 	mutable signed int chapter;
 	mutable signed int verse;
+
 	/** flag for auto normalization 
 	*/
 	char autonorm;
+
 	/** flag for headings on/off
 	*/
 	char headings;
 
 	int getBookAbbrev(const char *abbr);
 	void initBounds() const;
+
 	/** initialize and allocate books array
 	*/
 	void initstatics();
+
 	/** initializes this VerseKey()
 	*/
 	void init();
-	/** Refresh keytext based on testament|book|chapter|verse
-	* default auto normalization to true
-	* default display headings option is false
-	*/
-	void freshtext() const;
-	/**	Parse a character array into testament|book|chapter|verse 
-	*
-	*/
-	virtual char parse();
+
 	/** Binary search to find the index closest, but less
 	* than the given value.
 	*
@@ -153,8 +150,21 @@
 	* @return the index into the array that is less than but closest to value
 	*/
 	int findindex(long *array, int size, long value);
+
 	mutable VerseKey *lowerBound, *upperBound;
 
+
+protected:
+
+	/** Refresh keytext based on testament|book|chapter|verse
+	* default auto normalization to true
+	* default display headings option is false
+	*/
+	void freshtext() const;
+	/**	Parse a character array into testament|book|chapter|verse 
+	*
+	*/
+	virtual char parse();
 public:
 #if 0
 	static long otbks[];
@@ -244,11 +254,11 @@
 	virtual const char *getText() const;
 	virtual const char *getShortText() const;
 	virtual void setText(const char *ikey) { SWKey::setText(ikey); parse (); }
-	virtual void copyFrom(const SWKey & ikey);
+	virtual void copyFrom(const SWKey &ikey);
 	
 	/** Equates this VerseKey to another VerseKey
 	*/
-	virtual void copyFrom(const VerseKey & ikey);
+	virtual void copyFrom(const VerseKey &ikey);
 	
 	/** Positions this key
 	*

Added: trunk/include/versetreekey.h
===================================================================
--- trunk/include/versetreekey.h	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/include/versetreekey.h	2006-05-22 01:07:17 UTC (rev 1917)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ *	versekey.h - code for class 'versekey'- a standard Biblical verse key
+ *
+ * $Id: versekey.h 1864 2005-11-20 06:06:40Z scribe $
+ *
+ * Copyright 1998 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.
+ *
+ */
+
+
+#ifndef VERSETREEKEY_H
+#define VERSETREEKEY_H
+
+#include <versekey.h>
+#include <treekey.h>
+#include <swmacs.h>
+#include <listkey.h>
+
+#include <defs.h>
+
+SWORD_NAMESPACE_START
+
+/**
+ * Class VerseKey
+ * The SWKey implementation used for verse based modules like Bibles or commentaries.
+ */
+class SWDLLEXPORT VerseTreeKey : public VerseKey {
+
+	static SWClass classdef;
+	TreeKey *treeKey;
+
+public:
+
+	/**
+	* VerseKey Constructor - initializes Instance of VerseKey
+	*
+	* @param ikey text key (will take various forms of 'BOOK CH:VS'.
+	* See parse() for more detailed information)
+	*/
+	VerseTreeKey(TreeKey *treeKey, const char *ikey = 0);
+	
+	/**
+	* VerseKey Constructor - initializes instance of VerseKey
+	*
+	* @param ikey base key (will take various forms of 'BOOK CH:VS'.
+	*	See parse() for more detailed information)
+	*/	
+	VerseTreeKey(TreeKey *treeKey, const SWKey *ikey);
+	
+	/** VerseKey Constructor - initializes instance of VerseKey
+	* with boundariess - see also LowerBound()
+	* and UpperBound()
+	* @param min the lower boundary of the new	VerseKey
+	* @param max the upper boundary of the new	VerseKey
+	*/	
+	VerseTreeKey(TreeKey *treeKey, const char *min, const char *max);
+	
+	/**	VerseKey Copy Constructor - will create a new	VerseKey
+	* based on an existing one
+	*
+	* @param k the	VerseKey to copy from
+	*/
+	VerseTreeKey(const VerseTreeKey &k);
+	
+	/**	VerseKey Destructor
+	* Cleans up an instance of VerseKey
+	*/
+	virtual ~VerseTreeKey();
+
+	/** Creates a new	SWKey based on the current	VerseKey
+	* see also the Copy Constructor
+	*/
+	virtual SWKey *clone() const;
+	
+	virtual bool isTraversable() { return true; }
+
+	virtual TreeKey *getTreeKey() { return treeKey; }
+	
+
+	// OPERATORS --------------------------------------------------------------------
+
+
+	SWKEY_OPERATORS
+
+	virtual SWKey & operator = (const VerseKey & ikey) { copyFrom(ikey); return *this; }
+};
+
+SWORD_NAMESPACE_END
+
+#endif //VERSETREEKEY_H

Modified: trunk/src/keys/Makefile.am
===================================================================
--- trunk/src/keys/Makefile.am	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/keys/Makefile.am	2006-05-22 01:07:17 UTC (rev 1917)
@@ -6,4 +6,5 @@
 libsword_la_SOURCES += $(keysdir)/treekey.cpp
 libsword_la_SOURCES += $(keysdir)/treekeyidx.cpp
 libsword_la_SOURCES += $(keysdir)/versekey.cpp
+libsword_la_SOURCES += $(keysdir)/versetreekey.cpp
 

Added: trunk/src/keys/versetreekey.cpp
===================================================================
--- trunk/src/keys/versetreekey.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/keys/versetreekey.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ *  VerseTreeKey.cpp - code for class 'VerseTreeKey'- versekey using treekey
+ *		for data retrieval
+ */
+
+#include <versetreekey.h>
+
+SWORD_NAMESPACE_START
+
+static const char *classes[] = {"VerseTreeKey", "VerseKey", "SWKey", "SWObject", 0};
+SWClass VerseTreeKey::classdef(classes);
+
+
+/******************************************************************************
+ * VerseTreeKey Constructor - initializes instance of VerseTreeKey
+ *
+ * ENT:	ikey - base key (will take various forms of 'BOOK CH:VS'.  See
+ *		VerseTreeKey::parse for more detailed information)
+ */
+
+VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const SWKey *ikey) : VerseKey(ikey)
+{
+	this->treeKey = treeKey;
+	if (ikey)
+		parse();
+}
+
+
+/******************************************************************************
+ * VerseTreeKey Constructor - initializes instance of VerseTreeKey
+ *
+ * ENT:	ikey - text key (will take various forms of 'BOOK CH:VS'.  See
+ *		VerseTreeKey::parse for more detailed information)
+ */
+
+VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const char *ikey) : VerseKey(ikey)
+{
+	this->treeKey = treeKey;
+	if (ikey)
+		parse();
+}
+
+
+VerseTreeKey::VerseTreeKey(VerseTreeKey const &k) : VerseKey(k)
+{
+	treeKey = k.treeKey;
+}
+
+
+VerseTreeKey::VerseTreeKey(TreeKey *treeKey, const char *min, const char *max) : VerseKey(min, max)
+{
+	this->treeKey = treeKey;
+}
+
+
+SWKey *VerseTreeKey::clone() const
+{
+	return new VerseTreeKey(*this);
+}
+
+
+/******************************************************************************
+ * VerseTreeKey Destructor - cleans up instance of VerseTreeKey
+ *
+ * ENT:	ikey - text key
+ */
+
+VerseTreeKey::~VerseTreeKey() {
+}
+
+
+SWORD_NAMESPACE_END

Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/mgr/swmgr.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -815,7 +815,8 @@
 	}
 
 	if (!stricmp(driver, "RawGenBook")) {
-		newmod = new RawGenBook(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
+		misc1 = ((entry = section.find("KeyType")) != section.end()) ? (*entry).second : (SWBuf)"TreeKey";
+		newmod = new RawGenBook(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str(), "VerseKey");
 		pos = 1;
 	}
 

Modified: trunk/src/modules/filters/gbfstrongs.cpp
===================================================================
--- trunk/src/modules/filters/gbfstrongs.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/filters/gbfstrongs.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -68,6 +68,7 @@
 					if (atoi((!isdigit(*val))?val+1:val) < 5627) {
 						// normal strongs number
 						sprintf(wordstr, "%03d", word++);
+						module->getEntryAttributes()["Word"][wordstr]["PartsCount"] = "1";
 						module->getEntryAttributes()["Word"][wordstr]["Lemma"] = val;
 						module->getEntryAttributes()["Word"][wordstr]["LemmaClass"] = "strong";
 						tmp = "";

Modified: trunk/src/modules/filters/osisstrongs.cpp
===================================================================
--- trunk/src/modules/filters/osisstrongs.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/filters/osisstrongs.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -37,7 +37,6 @@
 	bool intoken = false;
 	bool lastspace = false;
 	int wordNum = 1;
-	char val[128];
 	char wordstr[5];
 	char *valto;
 	char *ch;
@@ -66,42 +65,108 @@
 						vkey = SWDYNAMIC_CAST(VerseKey, key);
 					}
 					XMLTag wtag(token);
-					SWBuf lemma      = wtag.getAttribute("lemma");
-					SWBuf morph      = wtag.getAttribute("morph");
-					SWBuf src        = wtag.getAttribute("src");
+					SWBuf lemma      = "";
+					SWBuf morph      = "";
+					SWBuf src        = "";
 					SWBuf morphClass = "";
 					SWBuf lemmaClass = "";
 
+					const char *attrib;
+					const char *val;
+					sprintf(wordstr, "%03d", wordNum);
+					if (attrib = wtag.getAttribute("morph")) {
+						int count = wtag.getAttributePartCount("morph", ' ');
+						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+						do {
+							SWBuf mClass = "";
+							SWBuf mp = "";
+							attrib = wtag.getAttribute("morph", i, ' ');
+							if (i < 0) i = 0;	// to handle our -1 condition
 
-					const char *m = strchr(morph.c_str(), ':');
-					if (m) {
-						int len = m-morph.c_str();
-						morphClass.append(morph.c_str(), len);
-						morph << len+1;
+							const char *m = strchr(attrib, ':');
+							if (m) {
+								int len = m-attrib;
+								mClass.append(attrib, len);
+								attrib += (len+1);
+							}
+							if ((mClass == "x-Robinsons") || (mClass == "x-Robinson") || (mClass == "Robinson")) {
+								mClass = "robinson";
+							}
+							if (i) { morphClass += " "; morph += " "; }
+							mp += attrib;
+							morphClass += mClass;
+							morph += mp;
+							if (count > 1) {
+								SWBuf tmp;
+								tmp.setFormatted("Morph.%d", i+1);
+								module->getEntryAttributes()["Word"][wordstr][tmp] = mp;
+								tmp.setFormatted("MorphClass.%d", i+1);
+								module->getEntryAttributes()["Word"][wordstr][tmp] = mClass;
+							}
+						} while (++i < count);
 					}
-					m = strchr(lemma.c_str(), ':');
-					if (m) {
-						int len = m-lemma.c_str();
-						lemmaClass.append(lemma.c_str(), len);
-						lemma << len+1;
+
+					if (attrib = wtag.getAttribute("lemma")) {
+						int count = wtag.getAttributePartCount("lemma", ' ');
+						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+						do {
+							SWBuf lClass = "";
+							SWBuf l = "";
+							attrib = wtag.getAttribute("lemma", i, ' ');
+							if (i < 0) i = 0;	// to handle our -1 condition
+
+							const char *m = strchr(attrib, ':');
+							if (m) {
+								int len = m-attrib;
+								lClass.append(attrib, len);
+								attrib += (len+1);
+							}
+							if ((lClass == "x-Strongs") || (lClass == "strong")) {
+								gh = isdigit(attrib[0]) ? 0:attrib[0];
+								if (!gh) {
+									if (vkey) {
+										gh = vkey->Testament() ? 'H' : 'G';
+									}
+								}
+								else attrib++;
+								lClass = "strong";
+							}
+							if (gh) l += gh;
+							l += attrib;
+							if (i) { lemmaClass += " "; lemma += " "; }
+							lemma += l;
+							lemmaClass += lClass;
+							if (count > 1) {
+								SWBuf tmp;
+								tmp.setFormatted("Lemma.%d", i+1);
+								module->getEntryAttributes()["Word"][wordstr][tmp] = l;
+								tmp.setFormatted("LemmaClass.%d", i+1);
+								module->getEntryAttributes()["Word"][wordstr][tmp] = lClass;
+							}
+						} while (++i < count);
+						module->getEntryAttributes()["Word"][wordstr]["PartCount"].setFormatted("%d", count);
 					}
 
-					if ((lemmaClass == "x-Strongs") || (lemmaClass == "strong")) {
-						gh = isdigit(lemma[0]) ? 0:lemma[0];
-						if (!gh) {
-							if (vkey) {
-								gh = vkey->Testament() ? 'H' : 'G';
+					if (attrib = wtag.getAttribute("src")) {
+						int count = wtag.getAttributePartCount("src", ' ');
+						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+						do {
+							SWBuf mp = "";
+							attrib = wtag.getAttribute("src", i, ' ');
+							if (i < 0) i = 0;	// to handle our -1 condition
+
+							if (i) src += " ";
+							mp += attrib;
+							src += mp;
+							if (count > 1) {
+								SWBuf tmp;
+								tmp.setFormatted("Src.%d", i+1);
+								module->getEntryAttributes()["Word"][wordstr][tmp] = mp;
 							}
-						}
-						else lemma << 1;
-						lemmaClass = "strong";
+						} while (++i < count);
 					}
-					if ((morphClass == "x-Robinsons") || (morphClass == "x-Robinson") || (morphClass == "Robinson")) {
-						morphClass = "robinson";
-					}
 
-					sprintf(wordstr, "%03d", wordNum);
-					if (gh) lemma.insert(0,gh);
+
 					if (lemma.length())
 					module->getEntryAttributes()["Word"][wordstr]["Lemma"] = lemma;
 					if (lemmaClass.length())

Modified: trunk/src/modules/filters/osiswebif.cpp
===================================================================
--- trunk/src/modules/filters/osiswebif.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/filters/osiswebif.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -69,10 +69,10 @@
 					buf.appendFormatted(" %s", val);
 				}
 				if (attrib = tag.getAttribute("lemma")) {
-					int count = tag.getAttributePartCount("lemma");
+					int count = tag.getAttributePartCount("lemma", ' ');
 					int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 					do {
-						attrib = tag.getAttribute("lemma", i);
+						attrib = tag.getAttribute("lemma", i, ' ');
 						if (i < 0) i = 0;	// to handle our -1 condition
 						val = strchr(attrib, ':');
 						val = (val) ? (val + 1) : attrib;
@@ -89,10 +89,10 @@
 					if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
 						show = false;
 					if (show) {
-						int count = tag.getAttributePartCount("morph");
+						int count = tag.getAttributePartCount("morph", ' ');
 						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 						do {
-							attrib = tag.getAttribute("morph", i);
+							attrib = tag.getAttribute("morph", i, ' ');
 							if (i < 0) i = 0;	// to handle our -1 condition
 							val = strchr(attrib, ':');
 							val = (val) ? (val + 1) : attrib;

Modified: trunk/src/modules/filters/osiswordjs.cpp
===================================================================
--- trunk/src/modules/filters/osiswordjs.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/filters/osiswordjs.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -44,12 +44,18 @@
 		bool intoken = false;
 		bool lastspace = false;
 		int wordNum = 1;
+		char wordstr[5];
 		char val[128];
 		char *valto;
 		char *ch;
 		SWBuf modName = (module)?module->Name():"";
 		// add TR to w src in KJV then remove this next line
 		SWBuf wordSrcPrefix = (modName == "KJV")?SWBuf("TR"):modName;
+
+		VerseKey *vkey = 0;
+		if (key) {
+			vkey = SWDYNAMIC_CAST(VerseKey, key);
+		}
 		
 		const SWBuf orig = text;
 		const char * from = orig.c_str();
@@ -67,52 +73,63 @@
 				intoken = false;
 				if ((*token == 'w') && (token[1] == ' ')) {	// Word
 					XMLTag wtag(token);
-					SWBuf lemma = wtag.getAttribute("lemma");
-					SWBuf strong = "";
-					SWBuf morph = wtag.getAttribute("morph");
-					SWBuf xlit = wtag.getAttribute("xlit");
-					SWBuf src = wtag.getAttribute("src");
-					if (!src.length()) src.appendFormatted("%d", wordNum);
-					src.insert(0, wordSrcPrefix);
+					sprintf(wordstr, "%03d", wordNum);
+					SWBuf lemmaClass;
+					SWBuf lemma;
+					SWBuf morph;
+					SWBuf src;
 					char gh = 0;
-					VerseKey *vkey = 0;
-					if (key) {
-						vkey = SWDYNAMIC_CAST(VerseKey, key);
+					int count = atoi(module->getEntryAttributes()["Word"][wordstr]["PartCount"].c_str());
+					for (int i = 0; i < count; i++) {
+
+						// for now, lemma class can just be equal to last lemma class in multi part word
+						SWBuf tmp = "LemmaClass";
+						if (count > 1) tmp.appendFormatted(".%d", i+1);
+						lemmaClass = module->getEntryAttributes()["Word"][wordstr][tmp];
+
+						tmp = "Lemma";
+						if (count > 1) tmp.appendFormatted(".%d", i+1);
+						tmp = (module->getEntryAttributes()["Word"][wordstr][tmp].c_str());
+
+						// if we're strongs, 
+						if (lemmaClass == "strong") {
+							gh = tmp[0];
+							tmp << 1;
+						}
+						if (lemma.size()) lemma += "|";
+						lemma += tmp;
+
+						tmp = "Morph";
+						if (count > 1) tmp.appendFormatted(".%d", i+1);
+						tmp = (module->getEntryAttributes()["Word"][wordstr][tmp].c_str());
+						if (morph.size()) morph += "|";
+						morph += tmp;
+
+						tmp = "Src";
+						if (count > 1) tmp.appendFormatted(".%d", i+1);
+						tmp = (module->getEntryAttributes()["Word"][wordstr][tmp].c_str());
+						if (!tmp.length()) tmp.appendFormatted("%d", wordNum);
+						tmp.insert(0, wordSrcPrefix);
+						if (src.size()) src += "|";
+						src += tmp;
 					}
+
 					SWBuf lexName = "";
-					if ((!strncmp(lemma.c_str(), "x-Strongs:", 10)) || (!strncmp(lemma.c_str(), "strong:", 7))) {
-						const char *num = strstr(lemma.c_str(), ":");
-						num++;
-						gh = isdigit(*num) ? 0:*num;
-						if (!gh) {
-							if (vkey) {
-								gh = vkey->Testament() ? 'H' : 'G';
-							}
-						}
-						else num++;
-						strong = num;
-						SWModule *sLex = 0;
-						if (gh == 'G') {
-							sLex = defaultGreekLex;
-						}
-						if (gh == 'H') {
-							sLex = defaultHebLex;
-						}
-						if (sLex) {
-							// we can pass the real lex name in, but we have some
-							// aliases in the javascript to optimize bandwidth
-							lexName = sLex->Name();
-							if (lexName == "StrongsGreek")
-								lexName = "G";
-							if (lexName == "StrongsHebrew")
-								lexName = "H";
-						}
+					// we can pass the real lex name in, but we have some
+					// aliases in the javascript to optimize bandwidth
+					if (gh == 'G') {
+						lexName = (!strcmp(defaultGreekLex->Name(), "StrongsGreek"))?"G":defaultGreekLex->Name();
 					}
-					else if (!strncmp(xlit.c_str(), "betacode:", 9)) {
+					else if (gh == 'H') {
+						lexName = (!strcmp(defaultHebLex->Name(), "StrongsHebrew"))?"H":defaultHebLex->Name();
+					}
+
+					SWBuf xlit = wtag.getAttribute("xlit");
+
+					if ((lemmaClass != "strong") && (xlit.startsWith("betacode:"))) {
 						lexName = "betacode";
 //						const char *m = strchr(xlit.c_str(), ':');
 //						strong = ++m;
-						strong = lemma;
 					}
 					SWBuf wordID;
 					if (vkey) {
@@ -122,17 +139,15 @@
 					else {
 						wordID = key->getText();
 					}
+					wordID.appendFormatted("_%s", src.c_str());
+					// clean up our word ID for XHTML
 					for (int i = 0; i < wordID.size(); i++) {
 						if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) {
 							wordID[i] = '_';
 						}
 					}
-					wordID.appendFormatted("_%s", src.c_str());
 					// 'p' = 'fillpop' to save bandwidth
-					const char *m = strchr(morph.c_str(), ':');
-					if (m) m++;
-					else m = morph.c_str();
-					text.appendFormatted("<span class=\"clk\" onclick=\"p(\'%s\',\'%s\','%s','%s');\" >", lexName.c_str(), strong.c_str(), wordID.c_str(), m);
+					text.appendFormatted("<span class=\"clk\" onclick=\"p(\'%s\',\'%s\','%s','%s');\" >", lexName.c_str(), lemma.c_str(), wordID.c_str(), morph.c_str());
 					wordNum++;
 				}
 				if ((*token == '/') && (token[1] == 'w') && option) {	// Word

Modified: trunk/src/modules/filters/thmlstrongs.cpp
===================================================================
--- trunk/src/modules/filters/thmlstrongs.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/filters/thmlstrongs.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -69,6 +69,7 @@
 					if (atoi((!isdigit(*val))?val+1:val) < 5627) {
 						// normal strongs number
 						sprintf(wordstr, "%03d", word);
+						module->getEntryAttributes()["Word"][wordstr]["PartCount"] = "1";
 						module->getEntryAttributes()["Word"][wordstr]["Lemma"] = val;
 						module->getEntryAttributes()["Word"][wordstr]["LemmaClass"] = "strong";
 						tmp = "";

Modified: trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp
===================================================================
--- trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/src/modules/genbook/rawgenbook/rawgenbook.cpp	2006-05-22 01:07:17 UTC (rev 1917)
@@ -13,6 +13,7 @@
 #include <filemgr.h>
 #include <sysdata.h>
 #include <treekeyidx.h>
+#include <versetreekey.h>
 
 SWORD_NAMESPACE_START
 
@@ -24,14 +25,16 @@
  *	idisp	 - Display object to use for displaying
  */
 
-RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang)
+RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *keyType)
 		: SWGenBook(iname, idesc, idisp, enc, dir, mark, ilang) {
 
 	char *buf = new char [ strlen (ipath) + 20 ];
 
 	path = 0;
 	stdstr(&path, ipath);
+	verseKey = !strcmp("VerseKey", keyType);
 
+	if (verseKey) Type("Biblical Texts");
 
 	if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
 		path[strlen(path)-1] = 0;
@@ -79,13 +82,22 @@
 	__u32 offset = 0;
 	__u32 size = 0;
 
-	TreeKeyIdx *key = 0;
+	TreeKey *key = 0;
 	SWTRY {
-		key = SWDYNAMIC_CAST(TreeKeyIdx, (this->key));
+		key = SWDYNAMIC_CAST(TreeKey, (this->key));
 	}
 	SWCATCH ( ... ) {}
 
 	if (!key) {
+		VerseTreeKey *tkey = 0;
+		SWTRY {
+			tkey = SWDYNAMIC_CAST(VerseTreeKey, (this->key));
+		}
+		SWCATCH ( ... ) {}
+		if (tkey) key = tkey->getTreeKey();
+	}
+
+	if (!key) {
 		key = (TreeKeyIdx *)CreateKey();
 		(*key) = *(this->key);
 	}
@@ -201,7 +213,7 @@
 
 SWKey *RawGenBook::CreateKey() {
 	TreeKeyIdx *newKey = new TreeKeyIdx(path);
-	return newKey;
+	return (verseKey) ? (SWKey *)new VerseTreeKey(newKey) : newKey;
 }
 
 SWORD_NAMESPACE_END

Modified: trunk/usrinst.sh
===================================================================
--- trunk/usrinst.sh	2006-05-15 22:55:05 UTC (rev 1916)
+++ trunk/usrinst.sh	2006-05-22 01:07:17 UTC (rev 1917)
@@ -4,11 +4,11 @@
 OPTIONS="--disable-shared $OPTIONS"
 OPTIONS="--without-conf $OPTIONS"
 OPTIONS="--sysconfdir=/etc $OPTIONS"
-OPTIONS="--with-icu $OPTIONS"
 #OPTIONS="--with-vcl $OPTIONS"
-#OPTIONS="--enable-debug $OPTIONS"
+OPTIONS="--enable-debug $OPTIONS"
 #OPTIONS="--enable-profile $OPTIONS"
-OPTIONS="--with-lucene $OPTIONS"
+#OPTIONS="--with-lucene $OPTIONS"
+OPTIONS="--with-icu $OPTIONS"
 #OPTIONS="--without-curl $OPTIONS"
 #OPTIONS="--enable-tests $OPTIONS"
 OPTIONS="--disable-utilities $OPTIONS"



More information about the sword-cvs mailing list