[sword-svn] r2595 - trunk/examples/classes

scribe at crosswire.org scribe at crosswire.org
Mon Jan 31 18:50:26 MST 2011


Author: scribe
Date: 2011-01-31 18:50:25 -0700 (Mon, 31 Jan 2011)
New Revision: 2595

Added:
   trunk/examples/classes/verseranges.cpp
Modified:
   trunk/examples/classes/Makefile
Log:
added verse range example


Modified: trunk/examples/classes/Makefile
===================================================================
--- trunk/examples/classes/Makefile	2011-01-14 14:46:38 UTC (rev 2594)
+++ trunk/examples/classes/Makefile	2011-02-01 01:50:25 UTC (rev 2595)
@@ -1,4 +1,4 @@
-TARGETS= ciphercng swmgrex
+TARGETS= ciphercng swmgrex verseranges
 all: $(TARGETS)
 
 clean:

Added: trunk/examples/classes/verseranges.cpp
===================================================================
--- trunk/examples/classes/verseranges.cpp	                        (rev 0)
+++ trunk/examples/classes/verseranges.cpp	2011-02-01 01:50:25 UTC (rev 2595)
@@ -0,0 +1,76 @@
+#include <iostream>
+
+#include <swmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+using namespace sword;
+using namespace std;
+
+int main(int argc, char **argv) {
+
+	cout << "\n";
+
+	const char *modName = "KJVA";
+	SWMgr manager;
+	SWModule *bible = manager.getModule(modName);
+	if (!bible) {
+		cout << modName << " not installed for example.  Please install.\n\n";
+		exit(-1);
+	}
+
+	VerseKey *vk = (VerseKey *)bible->CreateKey();
+
+
+	// whole Bible
+	vk->LowerBound(*vk);
+	vk->setPosition(BOTTOM);
+	vk->UpperBound(*vk);
+	cout << vk->getRangeText() << "\n";
+
+
+	vk->ClearBounds();
+
+
+	// Old Testament
+	vk->setPosition(TOP);
+	vk->LowerBound(*vk);
+	// doesn't work because MAXBOOK hasn't been implemented in versekey.cpp:1159
+//	vk->setPosition(MAXBOOK); vk->setPosition(MAXCHAPTER); vk->setPosition(MAXVERSE);
+	vk->setTestament(2);
+	(*vk)--;
+//	---- end of workaround
+	vk->UpperBound(*vk);
+	cout << vk->getRangeText() << "\n";
+
+
+	vk->ClearBounds();
+
+
+	// New Testament
+	vk->setPosition(TOP);	// stupid workaround to set book, chap, and verse to 1 because setTestament doesn't follow suit and do this like setChapter and setBook do.
+	vk->setTestament(2);
+	vk->LowerBound(*vk);
+	vk->setPosition(BOTTOM);
+	vk->UpperBound(*vk);
+	cout << vk->getRangeText() << "\n";
+
+
+	vk->ClearBounds();
+
+
+	// Current Book
+	vk->setText("John 3:16");
+	vk->setChapter(1); vk->setVerse(1);
+	vk->LowerBound(*vk);
+	vk->setChapter(vk->getChapterMax()); vk->setVerse(vk->getVerseMax());
+	vk->UpperBound(*vk);
+	cout << vk->getRangeText() << "\n";
+
+
+	delete vk;
+
+	cout << endl;
+
+	return 0;
+}




More information about the sword-cvs mailing list