[sword-svn] r2645 - in trunk: include src/keys src/mgr src/modules src/modules/comments src/modules/texts tests

scribe at crosswire.org scribe at crosswire.org
Fri Jul 22 04:03:46 MST 2011


Author: scribe
Date: 2011-07-22 04:03:45 -0700 (Fri, 22 Jul 2011)
New Revision: 2645

Modified:
   trunk/include/listkey.h
   trunk/include/swcom.h
   trunk/include/swkey.h
   trunk/include/swmodule.h
   trunk/include/swtext.h
   trunk/include/treekey.h
   trunk/include/versekey.h
   trunk/src/keys/versekey.cpp
   trunk/src/mgr/filemgr.cpp
   trunk/src/modules/comments/swcom.cpp
   trunk/src/modules/swmodule.cpp
   trunk/src/modules/texts/swtext.cpp
   trunk/tests/versekeytest.cpp
Log:
Fixed filemgr.cpp compile problem from temporary debug code left in
More normalization of API method names


Modified: trunk/include/listkey.h
===================================================================
--- trunk/include/listkey.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/listkey.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -124,7 +124,7 @@
 	virtual void increment(int step = 1);
 
 	virtual bool isTraversable() const { return true; }
-	virtual long Index() const { return arraypos; }
+	virtual long getIndex() const { return arraypos; }
 	virtual const char *getRangeText() const;
 	virtual const char *getOSISRefRangeText() const;
 
@@ -132,7 +132,7 @@
 	 * Returns the index for the new one given as as parameter.
 	 * The first parameter is the new index.
 	 */
-	virtual long Index(long index) { SetToElement(index); return Index (); }
+	virtual void setIndex(long index) { SetToElement(index); }
 	virtual const char *getText() const;
 	virtual void setText(const char *ikey);
 	virtual void sort();

Modified: trunk/include/swcom.h
===================================================================
--- trunk/include/swcom.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/swcom.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -70,8 +70,8 @@
 	virtual ~SWCom();
 	virtual SWKey *CreateKey() const;
 
-	virtual long Index() const;
-	virtual long Index(long iindex);
+	virtual long getIndex() const;
+	virtual void setIndex(long iindex);
 
 
 

Modified: trunk/include/swkey.h
===================================================================
--- trunk/include/swkey.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/swkey.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -216,11 +216,13 @@
 
 	/** Use this function to get an index position within a module.
 	 */
-	virtual long Index() const { return index; }
+	virtual long getIndex() const { return index; }
+	long Index() const { return getIndex(); }	// deprecated, use getIndex()
 
 	/** See documentation for @ref Index()
 	 */
-	virtual long Index(long iindex) { index = iindex; return index; }
+	virtual void setIndex(long iindex) { index = iindex; }
+	long Index(long iindex) { setIndex(iindex); return getIndex(); }	// deprecated, use setIndex(...)
 
 	SWKEY_OPERATORS
 

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/swmodule.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -241,8 +241,12 @@
 	}
 
 
-	virtual long Index() const { return entryIndex; }
-	virtual long Index(long iindex) { entryIndex = iindex; return entryIndex; }
+	virtual long getIndex() const { return entryIndex; }
+	virtual void setIndex(long iindex) { entryIndex = iindex; }
+	// deprecated, use getIndex()
+	long Index() const { return getIndex(); }
+	// deprecated, use setIndex(...)
+	long Index(long iindex) { setIndex(iindex); return getIndex(); }
 
 	/** Calls this module's display object and passes itself
 	 *

Modified: trunk/include/swtext.h
===================================================================
--- trunk/include/swtext.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/swtext.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -59,8 +59,8 @@
 	*/
 	virtual SWKey *CreateKey() const;
 
-	virtual long Index() const;
-	virtual long Index(long iindex);
+	virtual long getIndex() const;
+	virtual void setIndex(long iindex);
 
 	// OPERATORS -----------------------------------------------------------------
 	

Modified: trunk/include/treekey.h
===================================================================
--- trunk/include/treekey.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/treekey.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -123,8 +123,8 @@
 	virtual void decrement(int steps = 1) = 0;
 	virtual void increment(int steps = 1) = 0;
 	virtual bool isTraversable() const { return true; }
-	virtual long Index() const { return getOffset(); }
-	virtual long Index(long iindex) { setOffset(iindex); return getOffset(); }
+	virtual long getIndex() const { return getOffset(); }
+	virtual void setIndex(long iindex) { setOffset(iindex); }
 
 	/** Set the key to this path.  If the path doesn't exist, then
 	 *	nodes are created as necessary

Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/include/versekey.h	2011-07-22 11:03:45 UTC (rev 2645)
@@ -65,10 +65,6 @@
 	*/
 	char headings;
 
-	/** initialize and allocate books array
-	*/
-	void initstatics();
-
 	/** initializes this VerseKey()
 	*/
 	void init(const char *v11n = "KJV");
@@ -370,24 +366,28 @@
 	*/
 	virtual char Headings(char iheadings = MAXPOS(char));
 
+
 	/** Gets index based upon current verse
 	*
 	* @return offset
 	*/
-	virtual long Index() const;
+	virtual long getIndex() const;
 
+
 	/** Sets index based upon current verse
 	*
 	* @param iindex value to set index to
 	* @return offset
 	*/
-	virtual long Index(long iindex);
+	virtual void setIndex(long iindex);
 
+
 	/** Gets index into current testament based upon current verse
 	*
 	* @return offset
 	*/
-	virtual long TestamentIndex() const;
+	virtual long getTestamentIndex() const;
+	virtual long TestamentIndex() const { return getTestamentIndex(); }	// deprecated, use getTestamentIndex()
 
 	virtual const char *getOSISRef() const;
 	virtual const char *getOSISBookName() const;

Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/src/keys/versekey.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -985,7 +985,7 @@
 {
 	initBounds();
 
-	lowerBound = lb.Index();
+	lowerBound = lb.getIndex();
 	lowerBoundComponents.test   = lb.getTestament();
 	lowerBoundComponents.book   = lb.getBook();
 	lowerBoundComponents.chap   = lb.getChapter();
@@ -1010,7 +1010,7 @@
 {
 	initBounds();
 
-	upperBound = ub.Index();
+	upperBound = ub.getIndex();
 	upperBoundComponents.test   = ub.getTestament();
 	upperBoundComponents.book   = ub.getBook();
 	upperBoundComponents.chap   = ub.getChapter();
@@ -1039,7 +1039,7 @@
 		tmpClone->setVerse   (lowerBoundComponents.verse);
 		tmpClone->setSuffix  (lowerBoundComponents.suffix);
 	}
-	else tmpClone->Index(lowerBound);
+	else tmpClone->setIndex(lowerBound);
 
 	return (*tmpClone);
 }
@@ -1059,7 +1059,7 @@
 		tmpClone->setVerse   (upperBoundComponents.verse);
 		tmpClone->setSuffix  (upperBoundComponents.suffix);
 	}
-	else tmpClone->Index(upperBound);
+	else tmpClone->setIndex(upperBound);
 
 	return (*tmpClone);
 }
@@ -1087,7 +1087,7 @@
 		tmpClone->Book(BMAX[(BMAX[1])?1:0]);
 		tmpClone->Chapter(tmpClone->getChapterMax());
 		tmpClone->Verse(tmpClone->getVerseMax());
-		upperBound = tmpClone->Index();
+		upperBound = tmpClone->getIndex();
 		upperBoundComponents.test   = tmpClone->getTestament();
 		upperBoundComponents.book   = tmpClone->getBook();
 		upperBoundComponents.chap   = tmpClone->getChapter();
@@ -1214,9 +1214,9 @@
 
 void VerseKey::increment(int step) {
 	char ierror = 0;
-	Index(Index() + step);
+	setIndex(getIndex() + step);
 	while ((!verse) && (!headings) && (!ierror)) {
-		Index(Index() + 1);
+		setIndex(getIndex() + 1);
 		ierror = Error();
 	}
 
@@ -1235,9 +1235,9 @@
 void VerseKey::decrement(int step) {
 	char ierror = 0;
 
-	Index(Index() - step);
+	setIndex(getIndex() - step);
 	while ((!verse) && (!headings) && (!ierror)) {
-		Index(Index() - 1);
+		setIndex(getIndex() - 1);
 		ierror = Error();
 	}
 	if ((ierror) && (!headings))
@@ -1259,7 +1259,7 @@
 
 	if (((!autocheck) || (autonorm))	// only normalize if we were explicitely called or if autonorm is turned on
                &&
-	          ((!headings) || ((verse) && (chapter)))) {		// this is cheeze and temporary until deciding what actions should be taken; so headings should only be turned on when positioning with Index() or incrementors
+	          ((!headings) || ((verse) && (chapter)))) {		// this is cheeze and temporary until deciding what actions should be taken; so headings should only be turned on when positioning with setIndex() or incrementors
 		error = 0;
 
           while ((testament < 3) && (testament > 0)) {
@@ -1568,12 +1568,12 @@
 
 
 /******************************************************************************
- * VerseKey::Index - Gets index based upon current verse
+ * VerseKey::getIndex - Gets index based upon current verse
  *
  * RET:	offset
  */
 
-long VerseKey::Index() const
+long VerseKey::getIndex() const
 {
 	long  offset;
 
@@ -1591,27 +1591,26 @@
 
 
 /******************************************************************************
- * VerseKey::TestamentIndex - Gets index based upon current verse
+ * VerseKey::getTestamentIndex - Gets index based upon current verse
  *
  * RET:	offset
  */
 
-long VerseKey::TestamentIndex() const
+long VerseKey::getTestamentIndex() const
 {
-	long offset = Index();
+	long offset = getIndex();
 	return (testament > 1) ? offset - refSys->getNTStartOffset() : offset;
 }
 
 
 /******************************************************************************
- * VerseKey::Index - Sets index based upon current verse
+ * VerseKey::setIndex - Sets index based upon current verse
  *
  * ENT:	iindex - value to set index to
  *
- * RET:	offset
  */
 
-long VerseKey::Index(long iindex)
+void VerseKey::setIndex(long iindex)
 {
 	int b;
 	error = refSys->getVerseFromOffset(iindex, &b, &chapter, &verse);
@@ -1625,19 +1624,18 @@
 	if (book < 0) { testament = 0; book = 0; }
 	if (chapter < 0) { book = 0; chapter = 0; }
 
-	long i = Index();
+	long i = getIndex();
 
 	initBounds();
 	if (i > upperBound) {
-		i = Index(upperBound);
+		setIndex(upperBound);
+		i = getIndex();
 		error = KEYERR_OUTOFBOUNDS;
 	}
 	if (i < lowerBound) {
-		i = Index(lowerBound);
+		setIndex(lowerBound);
 		error = KEYERR_OUTOFBOUNDS;
 	}
-
-	return i;
 }
 
 

Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/src/mgr/filemgr.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -545,10 +545,13 @@
 			}
 		}
 		closedir(dir);
+		FileMgr::removeFile(targetDir);
+/*
 		int status = FileMgr::removeFile(targetDir);
           int stuff = errno;
           char *err = strerror(errno);
           int x = stuff;
+*/
 	}
 	return 0;
 }

Modified: trunk/src/modules/comments/swcom.cpp
===================================================================
--- trunk/src/modules/comments/swcom.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/src/modules/comments/swcom.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -68,22 +68,20 @@
 }
 
 
-long SWCom::Index() const {
+long SWCom::getIndex() const {
 	VerseKey *key = &getVerseKey();
-	entryIndex = key->Index();
+	entryIndex = key->getIndex();
 	return entryIndex;
 }
 
-long SWCom::Index(long iindex) {
+void SWCom::setIndex(long iindex) {
 	VerseKey *key = &getVerseKey();
 	key->Testament(1);
-	key->Index(iindex);
+	key->setIndex(iindex);
 
 	if (key != this->key) {
 		this->key->copyFrom(*key);
 	}
-
-	return Index();
 }
 
 

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/src/modules/swmodule.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -483,7 +483,7 @@
 	(*percent)(perc, percentUserData);
 
 	*this = BOTTOM;
-	long highIndex = key->Index();
+	long highIndex = key->getIndex();
 	if (!highIndex)
 		highIndex = 1;		// avoid division by zero errors.
 	*this = TOP;
@@ -607,7 +607,7 @@
 
 	
 	while ((searchType != -4) && !Error() && !terminateSearch) {
-		long mindex = key->Index();
+		long mindex = key->getIndex();
 		float per = (float)mindex / highIndex;
 		per *= 93;
 		per += 5;
@@ -619,7 +619,7 @@
 		else if (newperc < perc) {
 #ifndef _MSC_VER
 			std::cerr << "Serious error: new percentage complete is less than previous value\n";
-			std::cerr << "index: " << (key->Index()) << "\n";
+			std::cerr << "index: " << (key->getIndex()) << "\n";
 			std::cerr << "highIndex: " << highIndex << "\n";
 			std::cerr << "newperc ==" << (int)newperc << "%" << "is smaller than\n";
 			std::cerr << "perc == "  << (int )perc << "% \n";
@@ -1083,7 +1083,7 @@
 
 
 	*this = BOTTOM;
-	long highIndex = key->Index();
+	long highIndex = key->getIndex();
 	if (!highIndex)
 		highIndex = 1;		// avoid division by zero errors.
 
@@ -1100,7 +1100,7 @@
 
 	char err = Error();
 	while (!err) {
-		long mindex = key->Index();
+		long mindex = key->getIndex();
 
 		proxBuf = "";
 		proxLem = "";

Modified: trunk/src/modules/texts/swtext.cpp
===================================================================
--- trunk/src/modules/texts/swtext.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/src/modules/texts/swtext.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -70,24 +70,22 @@
 }
 
 
-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->setIndex(iindex);
 
 	if (key != this->key) {
 		this->key->copyFrom(*key);
 	}
-
-	return Index();
 }
 
 

Modified: trunk/tests/versekeytest.cpp
===================================================================
--- trunk/tests/versekeytest.cpp	2011-07-18 12:13:14 UTC (rev 2644)
+++ trunk/tests/versekeytest.cpp	2011-07-22 11:03:45 UTC (rev 2645)
@@ -31,8 +31,43 @@
 using std::cout;
 using std::endl;
 
+class _System {
+public:
+class Out {
+public:
+	void println(const char *x) { cout << x << endl; }
+	void println(int x) { cout << x << endl; }
+} out;
+} System;
+
 int main(int argc, char **argv) {
+		VerseKey vk;
 /*
+		vk.setTestament(2);
+		vk.setBook(4);
+		vk.setChapter(3);
+		vk.setVerse(1);
+		System.out.println(vk.getText());
+		System.out.println(vk.getIndex());
+		System.out.println(vk.getTestamentIndex());
+		vk.setVersificationSystem("KJVA");
+		System.out.println(vk.getText());
+		System.out.println(vk.getIndex());
+		System.out.println(vk.getTestamentIndex());
+		System.out.println("decrementing...");
+		vk.setVersificationSystem("KJV");
+		vk.decrement();
+		System.out.println(vk.getText());
+		System.out.println(vk.getIndex());
+		System.out.println(vk.getTestamentIndex());
+		vk.setVersificationSystem("KJVA");
+		System.out.println(vk.getText());
+		System.out.println(vk.getIndex());
+		System.out.println(vk.getTestamentIndex());
+*/
+
+
+/*
 VerseKey currentVerse;
 currentVerse.AutoNormalize(0);
 currentVerse.Headings(1);
@@ -118,7 +153,6 @@
 	(*mod)--;
 	cout << mod->getKeyText() << "\n";
 */
-	VerseKey vk;
 
 	cout << "\nNormalization on; headings on ====\n\n";
 




More information about the sword-cvs mailing list