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

scribe at crosswire.org scribe at crosswire.org
Wed May 6 09:07:19 MST 2020


Author: scribe
Date: 2020-05-06 09:07:19 -0700 (Wed, 06 May 2020)
New Revision: 3732

Added:
   trunk/examples/classes/verseconvert.cpp
Modified:
   trunk/examples/classes/Makefile
   trunk/examples/classes/simplechapter.cpp
Log:
Added simple example to show how to convert between versifications


Modified: trunk/examples/classes/Makefile
===================================================================
--- trunk/examples/classes/Makefile	2020-05-04 23:59:18 UTC (rev 3731)
+++ trunk/examples/classes/Makefile	2020-05-06 16:07:19 UTC (rev 3732)
@@ -1,4 +1,4 @@
-TARGETS= ciphercng swmgrex verseranges versevalid lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch versenorm flatapiinstallmgr
+TARGETS= ciphercng swmgrex verseranges versevalid lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch versenorm flatapiinstallmgr verseconvert
 all: $(TARGETS)
 
 clean:

Modified: trunk/examples/classes/simplechapter.cpp
===================================================================
--- trunk/examples/classes/simplechapter.cpp	2020-05-04 23:59:18 UTC (rev 3731)
+++ trunk/examples/classes/simplechapter.cpp	2020-05-06 16:07:19 UTC (rev 3732)
@@ -1,6 +1,10 @@
 /******************************************************************************
  *
- *  simplechapter.cpp -	
+ *  simplechapter.cpp -	this example shows how to display the entire chapter
+ *  of a given verse, marking the given verse within the chapter.
+ *  This example is very simple and doesn't set output markup or take into
+ *  account interverse material like chapter intros and section headings.
+ *  For a more complete example, see ../tasks/parallelbibles.cpp
  *
  * $Id$
  *

Added: trunk/examples/classes/verseconvert.cpp
===================================================================
--- trunk/examples/classes/verseconvert.cpp	                        (rev 0)
+++ trunk/examples/classes/verseconvert.cpp	2020-05-06 16:07:19 UTC (rev 3732)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ *
+ *  verseconvert.cpp -	This example shows how to convert a verse reference
+ *  from one versification to another.  This is a very simplistic usage.
+ *  For a complete example, see sword/examples/tasks/parallelbibles.cpp
+ *
+ * $Id: verseposition.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2020 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.
+ *
+ */
+
+#include <iostream>
+#include <swmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+
+using namespace sword;
+using namespace std;
+
+
+int main(int argc, char **argv) {
+
+	if (argc < 3) {
+		cerr << "\nUsage: " << *argv << " <key> <moduleNameFrom> <moduleNameTo>\n" << endl;
+		exit(-1);
+	}
+
+	const char *modNameFrom = argv[2];
+	const char *modNameTo = argv[3];
+
+	SWMgr library;
+        SWModule *modFrom = library.getModule(modNameFrom);
+        if (!modFrom) {
+                cerr << "Can't find module: " << modNameFrom << endl;
+                return -1;
+        }
+        SWModule *modTo = library.getModule(modNameTo);
+        if (!modTo) {
+                cerr << "Can't find module: " << modNameTo << endl;
+                return -1;
+        }
+
+	modFrom->setKey(argv[1]);
+	modTo->setKey(modFrom->getKey());
+
+	cout	<< modFrom->getKeyText()
+		<< " (" << modFrom->getName() << ") => "
+		<< modTo->getKey()->getRangeText()
+		<< " (" << modTo->getName() << ")\n" << endl;
+
+        return 0;
+}




More information about the sword-cvs mailing list