[sword-svn] r3382 - trunk/examples/cmdline
refdoc at crosswire.org
refdoc at crosswire.org
Tue Sep 1 14:33:51 MST 2015
Author: refdoc
Date: 2015-09-01 14:33:50 -0700 (Tue, 01 Sep 2015)
New Revision: 3382
Added:
trunk/examples/cmdline/stripaccents.cpp
Modified:
trunk/examples/cmdline/Makefile.am
Log:
added example/utility to strip accents from strings
Modified: trunk/examples/cmdline/Makefile.am
===================================================================
--- trunk/examples/cmdline/Makefile.am 2015-08-21 04:11:47 UTC (rev 3381)
+++ trunk/examples/cmdline/Makefile.am 2015-09-01 21:33:50 UTC (rev 3382)
@@ -5,10 +5,11 @@
endif
LDADD = $(top_builddir)/lib/libsword.la
-noinst_PROGRAMS = lookup search threaded_search listoptions verserangeparse outplain outrender
+noinst_PROGRAMS = lookup search threaded_search listoptions verserangeparse outplain outrender stripaccents
lookup_SOURCES = lookup.cpp
search_SOURCES = search.cpp
+stripaccents_SOURCES = stripaccents.cpp
listoptions_SOURCES = listoptions.cpp
verserangeparse_SOURCES = verserangeparse.cpp
threaded_search_SOURCES = threaded_search.cpp
Added: trunk/examples/cmdline/stripaccents.cpp
===================================================================
--- trunk/examples/cmdline/stripaccents.cpp (rev 0)
+++ trunk/examples/cmdline/stripaccents.cpp 2015-09-01 21:33:50 UTC (rev 3382)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ *
+ * 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:
+ *
+ * search KJV "swift hear slow speak"
+ *
+ * $Id: search.cpp 3269 2014-10-09 14:55:14Z scribe $
+ *
+ * Copyright 1997-2013 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 <cstdlib>
+#include <swmgr.h>
+#include <markupfiltmgr.h>
+#include <iostream>
+
+#ifndef NO_SWORD_NAMESPACE
+using namespace sword;
+#endif
+
+int usage()
+{
+ fprintf(stderr, "\nusage: stripaccents <n=1-15> <text-to-be-stripped> \n");
+ fprintf(stderr, "\n n=1 \t strip Greek accents");
+ fprintf(stderr, "\n n=2 \t strip Arabic vowel points");
+ fprintf(stderr, "\n n=4 \t strip Hebrew vowel points");
+ fprintf(stderr, "\n n=8 \t strip Hebrew Cantillation marks\n");
+ fprintf(stderr, "\n several of the above filters can be engaged by adding the values\n");
+ exit(0);
+}
+
+int main(int argc, char **argv)
+{
+// SWMgr manager(0, 0, true, new MarkupFilterMgr(FMT_RTF, ENC_RTF));
+ SWMgr manager;
+
+ if ((argc < 3) || (argc > 3)) {
+ usage();
+ exit(-1);
+ }
+
+ int stripFilters = atoi(argv[1]);
+
+ if ((stripFilters < 1) || (stripFilters > 15)) {
+ usage();
+ exit(-1);
+ }
+ SWBuf stripTerm = argv[2];
+
+ manager.setGlobalOption("Greek Accents", "Off");
+ manager.setGlobalOption("Arabic Vowel Points", "Off");
+ manager.setGlobalOption("Hebrew Vowel Points", "Off");
+ manager.setGlobalOption("Hebrew Cantillation", "Off");
+
+ if (stripFilters & (1 << 0)) manager.filterText("Hebrew Vowel Points", stripTerm);
+ if (stripFilters & (1 << 1)) manager.filterText("Hebrew Cantillation", stripTerm);
+ if (stripFilters & (1 << 2)) manager.filterText("Arabic Vowel Points", stripTerm);
+ if (stripFilters & (1 << 3)) manager.filterText("Greek Accents", stripTerm);
+
+ fprintf(stdout,"%s\n",stripTerm.c_str());
+ return 0;
+
+}
More information about the sword-cvs
mailing list