[sword-svn] r1931 - trunk/examples/cmdline
scribe at crosswire.org
scribe at crosswire.org
Sun Jun 11 15:23:35 MST 2006
Author: scribe
Date: 2006-06-11 15:23:34 -0700 (Sun, 11 Jun 2006)
New Revision: 1931
Modified:
trunk/examples/cmdline/lookup.cpp
Log:
updated poor example code
Modified: trunk/examples/cmdline/lookup.cpp
===================================================================
--- trunk/examples/cmdline/lookup.cpp 2006-06-11 20:44:27 UTC (rev 1930)
+++ trunk/examples/cmdline/lookup.cpp 2006-06-11 22:23:34 UTC (rev 1931)
@@ -4,21 +4,11 @@
#include <swmgr.h>
#include <swmodule.h>
-#ifndef NO_SWORD_NAMESPACE
-using sword::SWMgr;
-using sword::SWModule;
-using sword::ModMap;
-using sword::SWKey;
-using sword::AttributeTypeList;
-using sword::AttributeValue;
-using sword::AttributeList;
-#endif
int main(int argc, char **argv)
{
- SWMgr manager(0, 0, true, 0, true);
- SWModule *target;
- ModMap::iterator it;
+ sword::SWMgr manager(0, 0, true, 0, true);
+ sword::SWModule *target;
if (argc != 3) {
fprintf(stderr, "\nusage: %s <modname> <\"lookup key\">\n"
@@ -27,9 +17,10 @@
exit(-1);
}
- it = manager.Modules.find(argv[1]);
- if (it == manager.Modules.end()) {
+ target = manager.getModule(argv[1]);
+ if (!target) {
fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]);
+ sword::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());
}
@@ -39,21 +30,18 @@
manager.setGlobalOption("Headings", "On");
manager.setGlobalOption("Greek Accents", "Off");
- target = (*it).second;
-
target->setKey(argv[2]);
- (const char *)*target; // force an entry lookup to resolve key so we
- // get the idxbuf entry for the key
- std::cout << (const char *)(SWKey &)*target << ":\n";
-// std::cout << target->StripText();
+ target->RenderText(); // force an entry lookup to resolve key to something in the index
+
+ std::cout << target->getKeyText() << ":\n";
std::cout << target->getRawEntry();
std::cout << "\n";
std::cout << "==========================\n";
std::cout << "Entry Attributes:\n\n";
- AttributeTypeList::iterator i1;
- AttributeList::iterator i2;
- AttributeValue::iterator i3;
+ sword::AttributeTypeList::iterator i1;
+ sword::AttributeList::iterator i2;
+ sword::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++) {
More information about the sword-cvs
mailing list