[sword-svn] r3453 - in trunk: examples/cmdline include src/modules

scribe at crosswire.org scribe at crosswire.org
Sat Apr 22 18:26:51 MST 2017


Author: scribe
Date: 2017-04-22 18:26:51 -0700 (Sat, 22 Apr 2017)
New Revision: 3453

Modified:
   trunk/examples/cmdline/search.cpp
   trunk/include/swmodule.h
   trunk/src/modules/swmodule.cpp
Log:
Updated search examples and marked an unfinished search type as NOT DONE


Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp	2017-04-12 18:27:31 UTC (rev 3452)
+++ trunk/examples/cmdline/search.cpp	2017-04-23 01:26:51 UTC (rev 3453)
@@ -36,15 +36,17 @@
 using namespace sword;
 #endif
 
-/*
- *			>=0 - regex
- *			-1  - phrase
- *			-2  - multiword
- *			-3  - entryAttrib (eg. Word//Lemma/G1234/)
- *			-4  - Lucene
- */
+// FROM swmodule.h
+	/*
+	 *			>=0 - regex
+	 *			-1  - phrase
+	 *			-2  - multiword
+	 *			-3  - entryAttrib (eg. Word//Lemma./G1234/)	 (Lemma with dot means check components (Lemma.[1-9]) also)
+	 *			-4  - Lucene
+	 *			-5  - multilemma window; set 'flags' param to window size (NOT DONE)
+	 */
 
-char SEARCH_TYPE=-4;
+char SEARCH_TYPE=-2;
 
 char printed = 0;
 void percentUpdate(char percent, void *userData) {
@@ -68,7 +70,7 @@
 	SWMgr manager;
 	SWModule *target;
 	ListKey listkey;
-	ListKey scope;
+	ListKey *scope = 0;
 	ModMap::iterator it;
 
 	if ((argc < 3) || (argc > 5)) {
@@ -96,27 +98,25 @@
 
 	target = (*it).second;
 
+	ListKey maybeScope;
 	if (argc > 3) {			// if min / max specified
 		SWKey *k = target->getKey();
 		VerseKey *parser = SWDYNAMIC_CAST(VerseKey, k);
 		VerseKey kjvParser;
 		if (!parser) parser = &kjvParser;	// use standard KJV parsing as fallback
-		scope = parser->parseVerseList(argv[3], *parser, true);
-		scope.setPersist(true);
-		target->setKey(scope);
+		maybeScope = parser->parseVerseList(argv[3], *parser, true);
+		scope = &maybeScope;
 	}
 
 	std::cerr << "[0=================================50===============================100]\n ";
 	char lineLen = 70;
-	listkey = target->search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+	listkey = target->search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, scope, 0, &percentUpdate, &lineLen);
 	std::cerr << std::endl;
-	if (argc > 4) {			// if min / max specified
-		scope = listkey;
-		scope.setPersist(true);
-		target->setKey(scope);
+	if (argc > 4) {			// example: if a second search term is supplied, search again for a second search term, limiting to previous results
+		scope = &listkey;
 		printed = 0;
 		std::cerr << " ";
-		listkey = target->search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+		listkey = target->search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, scope, 0, &percentUpdate, &lineLen);
 		std::cerr << std::endl;
 	}
 // we don't want to sort by verse if we've been given scores

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2017-04-12 18:27:31 UTC (rev 3452)
+++ trunk/include/swmodule.h	2017-04-23 01:26:51 UTC (rev 3453)
@@ -389,20 +389,20 @@
 	 *			>=0 - regex
 	 *			-1  - phrase
 	 *			-2  - multiword
-	 *			-3  - entryAttrib (eg. Word//Strongs/G1234/)
+	 *			-3  - entryAttrib (eg. Word//Lemma./G1234/)	 (Lemma with dot means check components (Lemma.[1-9]) also)
 	 *			-4  - Lucene
+	 *			-5  - multilemma window; set 'flags' param to window size (NOT DONE)
 	 * @param flags options flags for search
 	 * @param scope Key containing the scope. VerseKey or ListKey are useful here.
-	 * @param justCheckIfSupported if set, don't search,
-	 * only tell if this function supports requested search.
+	 * @param justCheckIfSupported If set, don't search but instead set this variable to true/false if the requested search is supported,
 	 * @param percent Callback function to get the current search status in %.
-	 * @param percentUserData User data that is given to the callback function as parameter.
+	 * @param percentUserData Anything that you might want to send to the precent callback function.
 	 *
 	 * @return ListKey set to verses that contain istr
 	 */
 	virtual ListKey &search(const char *istr, int searchType = 0, int flags = 0,
-			SWKey * scope = 0,
-			bool * justCheckIfSupported = 0,
+			SWKey *scope = 0,
+			bool *justCheckIfSupported = 0,
 			void (*percent) (char, void *) = &nullPercent,
 			void *percentUserData = 0);
 

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2017-04-12 18:27:31 UTC (rev 3452)
+++ trunk/src/modules/swmodule.cpp	2017-04-23 01:26:51 UTC (rev 3453)
@@ -39,11 +39,13 @@
 #include <iostream>
 #endif
 
-#ifdef USECXX11REGEX
+#if defined(USECXX11REGEX)
 #include <regex>
 #ifndef REG_ICASE
 #define REG_ICASE std::regex::icase
 #endif
+#elif defined(USEICUREGEX)
+#include <unicode/regex.h>
 #else
 #include <regex.h>	// GNU
 #endif
@@ -786,6 +788,7 @@
 				}
 				break;
 			}
+			// NOT DONE
 			case -5:
 				AttributeList &words = getEntryAttributes()["Word"];
 				SWBuf kjvWord = "";




More information about the sword-cvs mailing list