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

scribe at crosswire.org scribe at crosswire.org
Mon Jan 11 10:40:25 MST 2016


Author: scribe
Date: 2016-01-11 10:40:24 -0700 (Mon, 11 Jan 2016)
New Revision: 3396

Added:
   trunk/examples/classes/versenorm.cpp
Modified:
   trunk/examples/classes/Makefile
Log:
Added new example to show how to check for normalization

Modified: trunk/examples/classes/Makefile
===================================================================
--- trunk/examples/classes/Makefile	2015-12-19 21:30:16 UTC (rev 3395)
+++ trunk/examples/classes/Makefile	2016-01-11 17:40:24 UTC (rev 3396)
@@ -1,4 +1,4 @@
-TARGETS= ciphercng swmgrex verseranges lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch
+TARGETS= ciphercng swmgrex verseranges lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch versenorm
 all: $(TARGETS)
 
 clean:

Added: trunk/examples/classes/versenorm.cpp
===================================================================
--- trunk/examples/classes/versenorm.cpp	                        (rev 0)
+++ trunk/examples/classes/versenorm.cpp	2016-01-11 17:40:24 UTC (rev 3396)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ *  versenorm.cpp -	checks normalization of verse to module
+ *
+ * $Id$
+ *
+ * Copyright 2012-2013 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) {
+
+        const char *modName = "RusCARS";
+        const char *keyTextRegular = "1Sam1.20";
+        const char *keyTextNeedsNormalization = "1Sam1.200";
+        SWMgr library;
+        SWModule *book = library.getModule(modName);
+        if (!book) {
+                cerr << "Can't find module: " << modName << endl;
+                return -1;
+        }
+        VerseKey *verse = ((VerseKey *)book->createKey());
+        VerseKey *verseNormalized = ((VerseKey *)book->createKey());
+
+        verse->setAutoNormalize(false);
+
+	verse->setText(keyTextRegular);
+	verseNormalized->setText(keyTextRegular);
+
+        cout << *verse << ((*verse) == (*verseNormalized) ? " == " : " != ") << *verseNormalized << endl;
+
+	verse->setText(keyTextNeedsNormalization);
+	verseNormalized->setText(keyTextNeedsNormalization);
+
+        cout << *verse << ((*verse) == (*verseNormalized) ? " == " : " != ") << *verseNormalized << endl;
+
+
+        return 0;
+}




More information about the sword-cvs mailing list