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

scribe at crosswire.org scribe at crosswire.org
Mon Mar 11 17:51:32 MST 2013


Author: scribe
Date: 2013-03-11 17:51:32 -0700 (Mon, 11 Mar 2013)
New Revision: 2789

Added:
   trunk/examples/classes/showchapter.cpp
Modified:
   trunk/examples/classes/Makefile
Log:
code to show a chapter


Modified: trunk/examples/classes/Makefile
===================================================================
--- trunk/examples/classes/Makefile	2013-02-27 14:48:13 UTC (rev 2788)
+++ trunk/examples/classes/Makefile	2013-03-12 00:51:32 UTC (rev 2789)
@@ -1,4 +1,4 @@
-TARGETS= ciphercng swmgrex verseranges lastVerseInChapter verseposition
+TARGETS= ciphercng swmgrex verseranges lastVerseInChapter verseposition showchapter
 all: $(TARGETS)
 
 clean:

Added: trunk/examples/classes/showchapter.cpp
===================================================================
--- trunk/examples/classes/showchapter.cpp	                        (rev 0)
+++ trunk/examples/classes/showchapter.cpp	2013-03-12 00:51:32 UTC (rev 2789)
@@ -0,0 +1,34 @@
+#include <swmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+#include <iostream>
+
+using namespace sword;
+using namespace std;
+
+int main(int argc, char **argv) {
+
+	SWMgr library;
+	SWModule *kjv = library.getModule("KJV");
+
+	kjv->setKey(argc > 1 ? argv[1] : "Jn.3.16");
+
+	VerseKey *key = (VerseKey *)kjv->getKey();
+
+	int curVerse = key->getVerse();
+	int curChapter = key->getChapter();
+	int curBook = key->getBook();
+
+	for (key->setVerse(1);
+		(key->getBook()    == curBook)    &&
+		(key->getChapter() == curChapter) &&
+		!kjv->popError();
+		(*kjv)++) {
+		if (key->getVerse() == curVerse) cout << "* ";
+		cout << key->getVerse() << " " << kjv->stripText() << "\n";
+
+	/* ... lots of hacking based on current key ... */
+	}
+
+	return 0;
+}




More information about the sword-cvs mailing list