[sword-svn] r2037 - trunk/examples/cmdline

scribe at www.crosswire.org scribe at www.crosswire.org
Tue Apr 24 11:05:15 MST 2007


Author: scribe
Date: 2007-04-24 11:05:15 -0700 (Tue, 24 Apr 2007)
New Revision: 2037

Modified:
   trunk/examples/cmdline/lookup.cpp
   trunk/examples/cmdline/search.cpp
Log:
Changed default search module to word.
Changed fully qualified sword namespaces to using clauses at top
Added web output as an example of how to ask sword for a particular render markup.


Modified: trunk/examples/cmdline/lookup.cpp
===================================================================
--- trunk/examples/cmdline/lookup.cpp	2007-04-24 17:37:38 UTC (rev 2036)
+++ trunk/examples/cmdline/lookup.cpp	2007-04-24 18:05:15 UTC (rev 2037)
@@ -3,12 +3,22 @@
 #include <stdlib.h>
 #include <swmgr.h>
 #include <swmodule.h>
+#include <markupfiltmgr.h>
 
+using sword::SWMgr;
+using sword::MarkupFilterMgr;
+using sword::SWModule;
+using sword::FMT_WEBIF;
+using sword::ModMap;
+using sword::AttributeTypeList;
+using sword::AttributeList;
+using sword::AttributeValue;
 
 int main(int argc, char **argv)
 {
-	sword::SWMgr manager(0, 0, true, 0, true);
-	sword::SWModule *target;
+	
+	SWMgr manager(new MarkupFilterMgr(FMT_WEBIF));
+	SWModule *target;
 
 	if (argc != 3) {
 		fprintf(stderr, "\nusage: %s <modname> <\"lookup key\">\n"
@@ -20,7 +30,7 @@
 	target = manager.getModule(argv[1]);
 	if (!target) {
 		fprintf(stderr, "Could not find module [%s].  Available modules:\n", argv[1]);
-		sword::ModMap::iterator it;
+		ModMap::iterator it;
 		for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) {
 			fprintf(stderr, "[%s]\t - %s\n", (*it).second->Name(), (*it).second->Description());
 		}
@@ -34,14 +44,18 @@
 
 	target->RenderText();		// force an entry lookup to resolve key to something in the index
 
+	std::cout << "==Raw=Entry===============\n";
 	std::cout << target->getKeyText() << ":\n";
 	std::cout << target->getRawEntry();
 	std::cout << "\n";
+	std::cout << "==Render=Entry============\n";
+	std::cout << target->RenderText();
+	std::cout << "\n";
 	std::cout << "==========================\n";
 	std::cout << "Entry Attributes:\n\n";
-	sword::AttributeTypeList::iterator i1;
-	sword::AttributeList::iterator i2;
-	sword::AttributeValue::iterator i3;
+	AttributeTypeList::iterator i1;
+	AttributeList::iterator i2;
+	AttributeValue::iterator i3;
 	for (i1 = target->getEntryAttributes().begin(); i1 != target->getEntryAttributes().end(); i1++) {
 		std::cout << "[ " << i1->first << " ]\n";
 		for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {

Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp	2007-04-24 17:37:38 UTC (rev 2036)
+++ trunk/examples/cmdline/search.cpp	2007-04-24 18:05:15 UTC (rev 2037)
@@ -75,7 +75,7 @@
 	 *			-3  - entryAttrib (eg. Word//Lemma/G1234/)
 	 *			-4  - Lucene
    */
-	listkey = target->Search(searchTerm.c_str(), -3, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+	listkey = target->Search(searchTerm.c_str(), -1, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
 	std::cout << "\n";
 	listkey.sort();
 	while (!listkey.Error()) {




More information about the sword-cvs mailing list