diff options
Diffstat (limited to 'examples/cmdline/search.cpp')
-rw-r--r-- | examples/cmdline/search.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/examples/cmdline/search.cpp b/examples/cmdline/search.cpp index 1542405..f437430 100644 --- a/examples/cmdline/search.cpp +++ b/examples/cmdline/search.cpp @@ -1,9 +1,14 @@ /****************************************************************************** - * This simple example shows how to perform a search on a SWORD module * - * $Id: search.cpp 2439 2009-08-10 02:37:42Z scribe $ + * search.cpp - This simple example shows how to perform a search on a + * SWORD module. It amounts to a simple commandline + * search tool with a usage like: * - * Copyright 1998-2009 CrossWire Bible Society (http://www.crosswire.org) + * search KJV "swift hear slow speak" + * + * $Id: search.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -31,13 +36,14 @@ using namespace sword; #endif - /* - * >=0 - regex - * -1 - phrase - * -2 - multiword - * -3 - entryAttrib (eg. Word//Lemma/G1234/) - * -4 - Lucene - */ +/* + * >=0 - regex + * -1 - phrase + * -2 - multiword + * -3 - entryAttrib (eg. Word//Lemma/G1234/) + * -4 - Lucene + */ + char SEARCH_TYPE=-2; char printed = 0; @@ -82,8 +88,8 @@ int main(int argc, char **argv) it = manager.Modules.find(argv[1]); if (it == manager.Modules.end()) { fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]); - for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) { - fprintf(stderr, "[%s]\t - %s\n", (*it).second->Name(), (*it).second->Description()); + for (it = manager.Modules.begin(); it != manager.Modules.end(); ++it) { + fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription()); } exit(-1); } @@ -95,8 +101,8 @@ int main(int argc, char **argv) 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.Persist(1); + scope = parser->parseVerseList(argv[3], *parser, true); + scope.setPersist(true); target->setKey(scope); } @@ -106,7 +112,7 @@ int main(int argc, char **argv) std::cerr << std::endl; if (argc > 4) { // if min / max specified scope = listkey; - scope.Persist(1); + scope.setPersist(true); target->setKey(scope); printed = 0; std::cerr << " "; @@ -114,9 +120,11 @@ int main(int argc, char **argv) std::cerr << std::endl; } listkey.sort(); - while (!listkey.Error()) { + while (!listkey.popError()) { std::cout << (const char *)listkey << std::endl; listkey++; } + return 0; + } |