summaryrefslogtreecommitdiff
path: root/examples/cmdline/search.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cmdline/search.cpp')
-rw-r--r--examples/cmdline/search.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/examples/cmdline/search.cpp b/examples/cmdline/search.cpp
index 31a9ad9..c696233 100644
--- a/examples/cmdline/search.cpp
+++ b/examples/cmdline/search.cpp
@@ -1,3 +1,24 @@
+/******************************************************************************
+ * This simple example shows how to perform a search on a SWORD module
+ *
+ * $Id: search.cpp 2327 2009-04-22 11:42:33Z scribe $
+ *
+ * Copyright 1998-2009 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
#include <stdio.h>
#include <rawtext.h>
#include <swmgr.h>
@@ -42,7 +63,6 @@ int main(int argc, char **argv)
SWModule *target;
ListKey listkey;
ListKey scope;
- VerseKey parser;
ModMap::iterator it;
if ((argc < 3) || (argc > 5)) {
@@ -70,14 +90,18 @@ int main(int argc, char **argv)
target = (*it).second;
if (argc > 3) { // if min / max specified
- scope = parser.ParseVerseList(argv[3], parser, true);
+ SWKey *k = target->getKey();
+ 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);
target->setKey(scope);
}
std::cerr << "[0=================================50===============================100]\n ";
char lineLen = 70;
- listkey = target->Search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+ listkey = target->search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cerr << std::endl;
if (argc > 4) { // if min / max specified
scope = listkey;
@@ -85,7 +109,7 @@ int main(int argc, char **argv)
target->setKey(scope);
printed = 0;
std::cerr << " ";
- listkey = target->Search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+ listkey = target->search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cerr << std::endl;
}
listkey.sort();