[sword-svn] r3787 - in trunk: examples/cmdline include src/mgr

scribe at crosswire.org scribe at crosswire.org
Sun Aug 30 08:00:38 EDT 2020


Author: scribe
Date: 2020-08-30 08:00:38 -0400 (Sun, 30 Aug 2020)
New Revision: 3787

Modified:
   trunk/examples/cmdline/search.cpp
   trunk/include/cipherfil.h
   trunk/include/swmgr.h
   trunk/src/mgr/swmgr.cpp
Log:
Separated out utilModules from Modules
Fixed a typo in cipherfil comments
Added range results in examples/cmdline/search


Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp	2020-08-30 11:35:14 UTC (rev 3786)
+++ trunk/examples/cmdline/search.cpp	2020-08-30 12:00:38 UTC (rev 3787)
@@ -128,11 +128,14 @@
 		listKey = target->search(argv[4], SEARCH_TYPE, flags, scope, 0, &percentUpdate, &lineLen);
 		std::cerr << std::endl;
 	}
+
+	// Simply print of all results
+	std::cout << "\n" << listKey.getShortRangeText() << "\n" << std::endl;
 // we don't want to sort by verse if we've been given scores
 //	listKey.sort();
 	for (listKey = TOP; !listKey.popError(); listKey.nextElement()) {
 		SWKey *k = listKey.getElement();
-		std::cout << k->getRangeText();
+		std::cout << k->getShortRangeText();
 //		std::cout << (const char *)listKey;
 		if (k->userData) std::cout << " : " << (SW_u64)k->userData << "%";
 		std::cout << std::endl;

Modified: trunk/include/cipherfil.h
===================================================================
--- trunk/include/cipherfil.h	2020-08-30 11:35:14 UTC (rev 3786)
+++ trunk/include/cipherfil.h	2020-08-30 12:00:38 UTC (rev 3787)
@@ -1,7 +1,7 @@
 /***************************************************************************
  *
  * cipherfil.h -	class CipherFilter: an EncodingFilter which can
- * 			encipher an decipher a text stream based on
+ * 			encipher and decipher a text stream based on
  * 			a CipherKey
  *
  * $Id$

Modified: trunk/include/swmgr.h
===================================================================
--- trunk/include/swmgr.h	2020-08-30 11:35:14 UTC (rev 3786)
+++ trunk/include/swmgr.h	2020-08-30 12:00:38 UTC (rev 3787)
@@ -92,6 +92,7 @@
  */
 class SWDLLEXPORT SWMgr {
 private:
+	ModMap utilModules;
 	bool mgrModeMultiMod;
 	bool augmentHome;
 	void commonInit(SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod = false);
@@ -342,6 +343,12 @@
 	ModMap &getModules();
 	const ModMap &getModules() const { return const_cast<SWMgr *>(this)->getModules(); }
 
+	/** Utility modules are not meant for user to see as general addins, but instead are
+	 * modules which provide utility tools for frontends which may wish to use them.
+	 */
+	ModMap &getUtilModules();
+	const ModMap &getUtilModules() const { return const_cast<SWMgr *>(this)->getUtilModules(); }
+
 	/** Gets a specific module by name.  e.g. SWModule *kjv = myManager.getModule("KJV");
 	 * @param modName the name of the module to retrieve
 	 * @return the module, if found, otherwise 0

Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2020-08-30 11:35:14 UTC (rev 3786)
+++ trunk/src/mgr/swmgr.cpp	2020-08-30 12:00:38 UTC (rev 3787)
@@ -1496,7 +1496,11 @@
 					delete oldmod;
 				}
 				
-				Modules[newmod->getName()] = newmod;
+				// if it's not a utility module save it to Modules
+				if (strcmp("Utility", newmod->getType())) {
+					Modules[newmod->getName()] = newmod;
+				}
+				else	utilModules[newmod->getName()] = newmod;
 			}
 		}
 	}
@@ -1510,13 +1514,18 @@
 	for (it = getModules().begin(); it != getModules().end(); ++it) {
 		delete (*it).second;
 	}
+	for (it = getUtilModules().begin(); it != getUtilModules().end(); ++it) {
+		delete (*it).second;
+	}
 
 	Modules.clear();
+	utilModules.clear();
 }
 
 
 void SWMgr::deleteModule(const char *modName) {
 	ModMap::iterator it = Modules.find(modName);
+	if (it == Modules.end()) it = utilModules.find(modName);
 	if (it != Modules.end()) {
 		delete (*it).second;
 		Modules.erase(it);
@@ -1536,6 +1545,7 @@
 	// check if module exists
 	else {
 		it2 = Modules.find(modName);
+		if (it2 == Modules.end()) it2 = utilModules.find(modName);
 		if (it2 != Modules.end()) {
 			SWFilter *cipherFilter = new CipherFilter(key);
 			cipherFilters.insert(FilterMap::value_type(modName, cipherFilter));
@@ -1549,6 +1559,7 @@
 
 
 ModMap &SWMgr::getModules() { return Modules; }
+ModMap &SWMgr::getUtilModules() { return utilModules; }
 
 SWBuf SWMgr::getHomeDir() { return FileMgr::getSystemFileMgr()->getHomeDir(); }
 



More information about the sword-cvs mailing list