[sword-svn] r2288 - in trunk: include src/modules/common src/modules/lexdict/rawld src/modules/lexdict/rawld4 src/modules/lexdict/zld

scribe at crosswire.org scribe at crosswire.org
Fri Mar 20 10:27:30 MST 2009


Author: scribe
Date: 2009-03-20 10:27:29 -0700 (Fri, 20 Mar 2009)
New Revision: 2288

Modified:
   trunk/include/rawld.h
   trunk/include/rawld4.h
   trunk/include/rawstr.h
   trunk/include/rawstr4.h
   trunk/include/swld.h
   trunk/include/zld.h
   trunk/src/modules/common/rawstr.cpp
   trunk/src/modules/common/rawstr4.cpp
   trunk/src/modules/lexdict/rawld/rawld.cpp
   trunk/src/modules/lexdict/rawld4/rawld4.cpp
   trunk/src/modules/lexdict/zld/zld.cpp
Log:
Applied Ben Morgan's patch to add 'Index' functionality to lexdict
Eventually maybe we should push this down to SWModule and move out of
SWKey.




Modified: trunk/include/rawld.h
===================================================================
--- trunk/include/rawld.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/rawld.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -55,6 +55,9 @@
 	virtual void linkEntry(const SWKey *linkKey);	// Link current module entry to other module entry
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
+	virtual long getEntryCount();
+	virtual long getEntryForKey(const char *key);
+	virtual char *getKeyForEntry(long entry);
 
 
 	// OPERATORS -----------------------------------------------------------------

Modified: trunk/include/rawld4.h
===================================================================
--- trunk/include/rawld4.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/rawld4.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -55,6 +55,9 @@
 	virtual void linkEntry(const SWKey *linkKey);	// Link current module entry to other module entry
 	virtual void deleteEntry();	// Delete current module entry
 	// end write interface ------------------------
+	virtual long getEntryCount();
+	virtual long getEntryForKey(const char *key);
+	virtual char *getKeyForEntry(long entry);
 
 
 	// OPERATORS -----------------------------------------------------------------

Modified: trunk/include/rawstr.h
===================================================================
--- trunk/include/rawstr.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/rawstr.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -37,12 +37,15 @@
 	static int instance;		// number of instantiated RawStr objects or derivitives
 	char *path;
 	long lastoff;
+	
 
 protected:
 	FileDesc *idxfd;
 	FileDesc *datfd;
 	void doSetText(const char *key, const char *buf, long len = -1);
 	void doLinkEntry(const char *destkey, const char *srckey);
+	static const int IDXENTRYSIZE;
+
 public:
 	static char nl;
 	RawStr(const char *ipath, int fileMode = -1);

Modified: trunk/include/rawstr4.h
===================================================================
--- trunk/include/rawstr4.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/rawstr4.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -39,6 +39,8 @@
 	long lastoff;
 
 protected:
+	static const int IDXENTRYSIZE;
+	
 	FileDesc *idxfd;
 	FileDesc *datfd;
 	void doSetText(const char *key, const char *buf, long len = -1);

Modified: trunk/include/swld.h
===================================================================
--- trunk/include/swld.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/swld.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -56,6 +56,11 @@
 	virtual void setPosition(SW_POSITION pos);
 
 
+	virtual long getEntryCount() = 0;
+	virtual long getEntryForKey(const char *key) = 0;
+	virtual char *getKeyForEntry(long entry) = 0;
+	
+
 	// OPERATORS -----------------------------------------------------------------
 	
 	SWMODULE_OPERATORS

Modified: trunk/include/zld.h
===================================================================
--- trunk/include/zld.h	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/include/zld.h	2009-03-20 17:27:29 UTC (rev 2288)
@@ -63,7 +63,11 @@
 	virtual void flush() { flushCache(); }
 	// end swcacher interface ----------------------
 
+	virtual long getEntryCount();
+	virtual long getEntryForKey(const char *key);
+	virtual char *getKeyForEntry(long entry);
 
+
 	// OPERATORS -----------------------------------------------------------------
 	
 	SWMODULE_OPERATORS

Modified: trunk/src/modules/common/rawstr.cpp
===================================================================
--- trunk/src/modules/common/rawstr.cpp	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/src/modules/common/rawstr.cpp	2009-03-20 17:27:29 UTC (rev 2288)
@@ -42,8 +42,10 @@
 
 int RawStr::instance = 0;
 char RawStr::nl = '\n';
+const int RawStr::IDXENTRYSIZE = 6;
 
 
+
 /******************************************************************************
  * RawStr Constructor - Initializes data for instance of RawStr
  *
@@ -484,7 +486,6 @@
 	delete [] text;
 }
 
-
 /******************************************************************************
  * RawLD::CreateModule	- Creates new module files
  *

Modified: trunk/src/modules/common/rawstr4.cpp
===================================================================
--- trunk/src/modules/common/rawstr4.cpp	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/src/modules/common/rawstr4.cpp	2009-03-20 17:27:29 UTC (rev 2288)
@@ -42,6 +42,7 @@
  */
 
 int RawStr4::instance = 0;
+const int RawStr4::IDXENTRYSIZE = 8;
 
 
 /******************************************************************************

Modified: trunk/src/modules/lexdict/rawld/rawld.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld/rawld.cpp	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/src/modules/lexdict/rawld/rawld.cpp	2009-03-20 17:27:29 UTC (rev 2288)
@@ -206,4 +206,26 @@
 	doSetText(*key, "");
 }
 
+
+long RawLD::getEntryCount() {
+	if (idxfd < 0) return 0;
+	return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
+}
+
+
+long RawLD::getEntryForKey(const char *key) {
+	__u32 start, offset;
+	__u16 size;
+
+	findOffset(key, &start, &size, 0, &offset);
+	return offset / IDXENTRYSIZE;
+}
+
+
+char *RawLD::getKeyForEntry(long entry) {
+	char *key = 0;
+	getIDXBuf(entry * IDXENTRYSIZE, &key);
+	return key;
+}
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/lexdict/rawld4/rawld4.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld4/rawld4.cpp	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/src/modules/lexdict/rawld4/rawld4.cpp	2009-03-20 17:27:29 UTC (rev 2288)
@@ -204,4 +204,23 @@
 	doSetText(*key, "");
 }
 
+long RawLD4::getEntryCount() {
+	if (idxfd < 0) return 0;
+	return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
+}
+
+long RawLD4::getEntryForKey(const char *key) {
+	__u32 start, offset;
+	__u32 size;
+
+	findOffset(key, &start, &size, 0, &offset);
+	return offset / IDXENTRYSIZE;
+}
+
+char *RawLD4::getKeyForEntry(long entry) {
+	char *key = 0;
+	getIDXBuf(entry * IDXENTRYSIZE, &key);
+	return key;
+}
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/lexdict/zld/zld.cpp
===================================================================
--- trunk/src/modules/lexdict/zld/zld.cpp	2009-03-18 09:32:09 UTC (rev 2287)
+++ trunk/src/modules/lexdict/zld/zld.cpp	2009-03-20 17:27:29 UTC (rev 2288)
@@ -200,4 +200,25 @@
 	setText(*key, "");
 }
 
+
+long zLD::getEntryCount() {
+	if (idxfd < 0) return 0;
+	return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
+}
+
+
+long zLD::getEntryForKey(const char *key) {
+	long offset;
+	findKeyIndex(key, &offset);
+	return offset / IDXENTRYSIZE;
+}
+
+
+char *zLD::getKeyForEntry(long entry) {
+	char *key = 0;
+	getKeyFromIdxOffset(entry * IDXENTRYSIZE, &key);
+	return key;
+}
+
+
 SWORD_NAMESPACE_END




More information about the sword-cvs mailing list