[sword-svn] r2901 - in trunk/src: mgr modules/filters

chrislit at crosswire.org chrislit at crosswire.org
Tue Jul 16 03:58:55 MST 2013


Author: chrislit
Date: 2013-07-16 03:58:55 -0700 (Tue, 16 Jul 2013)
New Revision: 2901

Modified:
   trunk/src/mgr/swmgr.cpp
   trunk/src/modules/filters/osisvariants.cpp
Log:
fixed OSISVariants filter and added it to SWMgr


Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2013-07-16 07:48:52 UTC (rev 2900)
+++ trunk/src/mgr/swmgr.cpp	2013-07-16 10:58:55 UTC (rev 2901)
@@ -61,6 +61,7 @@
 #include <osisredletterwords.h>
 #include <osismorphsegmentation.h>
 #include <osisscripref.h>
+#include <osisvariants.h>
 #include <osisxlit.h>
 #include <thmlstrongs.h>
 #include <thmlfootnotes.h>
@@ -204,6 +205,10 @@
 	optionFilters.insert(OptionFilterMap::value_type("OSISEnum", tmpFilter));
 	cleanupFilters.push_back(tmpFilter);
 
+	tmpFilter = new OSISVariants();
+	optionFilters.insert(OptionFilterMap::value_type("OSISVariants", tmpFilter));
+	cleanupFilters.push_back(tmpFilter);
+
 	tmpFilter = new ThMLStrongs();
 	optionFilters.insert(OptionFilterMap::value_type("ThMLStrongs", tmpFilter));
 	cleanupFilters.push_back(tmpFilter);

Modified: trunk/src/modules/filters/osisvariants.cpp
===================================================================
--- trunk/src/modules/filters/osisvariants.cpp	2013-07-16 07:48:52 UTC (rev 2900)
+++ trunk/src/modules/filters/osisvariants.cpp	2013-07-16 10:58:55 UTC (rev 2901)
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <osisvariants.h>
 #include <utilstr.h>
+#include <utilxml.h>
+#include <iostream>
 
 SWORD_NAMESPACE_START
 
@@ -36,7 +38,7 @@
 
 
 OSISVariants::OSISVariants() {
-	option = false;
+	option = 0;
 	options.push_back(primary);
 	options.push_back(secondary);
 	options.push_back(all);
@@ -55,7 +57,7 @@
 
 const char *OSISVariants::getOptionValue()
 {
-        if (option == 0) {
+    if (option == 0) {
 	        return primary;
 	}
 	else if (option == 1) {
@@ -76,9 +78,10 @@
 		SWBuf token;
 		SWBuf orig = text;
 		const char *from = orig.c_str();
+		XMLTag tag;
 
 		//we use a fixed comparision string to make sure the loop is as fast as the original two blocks with almost the same code
-		const char* variantCompareString = (option == 0) ? "seg type=\"x-variant\" subType=\"x-1\"" : "seg type=\"x-variant\" subType=\"x-2\"";
+		const char* variantChoice = (option == 0) ? "x-2" : "x-1";
 		
 		for (text = ""; *from; from++) {
 			if (*from == '<') {
@@ -89,10 +92,14 @@
 			else if (*from == '>') {	// process tokens
 				intoken = false;
 				
-				if (!strncmp(token.c_str(), variantCompareString, 34)) { //only one of the variants, length of the two strings is 34 in both cases
-					invar = true;
-					hide = true;
-					continue;
+				if (!strncmp(token.c_str(), "seg", 3)) {
+					tag = token;
+					
+					if (tag.getAttribute("type") && !strcmp("x-variant", tag.getAttribute("type")) && tag.getAttribute("subType") && !strcmp(variantChoice, tag.getAttribute("subType"))) {
+						invar = true;
+						hide = true;
+						continue;
+					}
 				}
 				if (!strncmp(token.c_str(), "/seg", 4)) {
 					hide = false;




More information about the sword-cvs mailing list