[sword-svn] r3621 - in trunk: examples/cmdline include

scribe at crosswire.org scribe at crosswire.org
Sun May 5 11:14:10 MST 2019


Author: scribe
Date: 2019-05-05 11:14:09 -0700 (Sun, 05 May 2019)
New Revision: 3621

Modified:
   trunk/examples/cmdline/listoptions.cpp
   trunk/include/swmodule.h
Log:
Added public exposure for SWModule::optionsFilters with example

Modified: trunk/examples/cmdline/listoptions.cpp
===================================================================
--- trunk/examples/cmdline/listoptions.cpp	2019-05-04 18:50:37 UTC (rev 3620)
+++ trunk/examples/cmdline/listoptions.cpp	2019-05-05 18:14:09 UTC (rev 3621)
@@ -26,17 +26,36 @@
 
 #include <iostream>
 #include <swmgr.h>
+#include <swmodule.h>
+#include <swoptfilter.h>
 
 
 using sword::SWMgr;
+using sword::SWModule;
 using sword::StringList;
+using sword::OptionFilterList;
 using std::cout;
+using std::cerr;
 
 
 int main(int argc, char **argv)
 {
 	SWMgr library;
 
+	// specific module features
+	if (argc == 2) {
+		SWModule *module = library.getModule(argv[1]);
+		if (!module) { cerr << "\nUnable to find module: " << argv[1] << "\n"; return 1; }
+		cout << "\nOption Features available for module: " << module->getName() << "\n\n";
+		for (OptionFilterList::const_iterator it = module->getOptionFilters().begin(); it != module->getOptionFilters().end(); ++it) {
+			cout << (*it)->getOptionName() << " (" << (*it)->getOptionTip() << ")\n";
+			StringList optionValues = (*it)->getOptionValues();
+			for (StringList::const_iterator it2 = optionValues.begin(); it2 != optionValues.end(); ++it2) {
+				cout << "\t" << *it2 << "\n";
+			}
+		}
+		return 0;
+	}
 	StringList options = library.getGlobalOptions();
 	for (StringList::const_iterator it = options.begin(); it != options.end(); ++it) {
 		cout << *it << " (" << library.getGlobalOptionTip(*it) << ")\n";

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2019-05-04 18:50:37 UTC (rev 3620)
+++ trunk/include/swmodule.h	2019-05-05 18:14:09 UTC (rev 3621)
@@ -631,6 +631,8 @@
 	}
 	SWDEPRECATED SWModule &AddOptionFilter(SWOptionFilter *newFilter) { return addOptionFilter(newFilter); }
 
+	virtual const OptionFilterList &getOptionFilters() const { return *optionFilters; }
+
 	/** OptionFilter a text buffer
 	 * @param buf the buffer to filter
 	 * @param key key location from where this buffer was extracted




More information about the sword-cvs mailing list