[sword-svn] r3608 - trunk/examples/cmdline
refdoc at crosswire.org
refdoc at crosswire.org
Mon Nov 12 13:14:12 MST 2018
Author: refdoc
Date: 2018-11-12 13:14:12 -0700 (Mon, 12 Nov 2018)
New Revision: 3608
Added:
trunk/examples/cmdline/outvplskeleton.cpp
Modified:
trunk/examples/cmdline/Makefile.am
Log:
output of a v11n conforming verse reference list
Modified: trunk/examples/cmdline/Makefile.am
===================================================================
--- trunk/examples/cmdline/Makefile.am 2018-11-12 15:38:12 UTC (rev 3607)
+++ trunk/examples/cmdline/Makefile.am 2018-11-12 20:14:12 UTC (rev 3608)
@@ -5,7 +5,7 @@
endif
LDADD = $(top_builddir)/lib/libsword.la
-noinst_PROGRAMS = lookup search threaded_search listoptions verserangeparse outplain outrender stripaccents
+noinst_PROGRAMS = lookup search threaded_search listoptions verserangeparse outplain outvplskeleton outrender stripaccents
lookup_SOURCES = lookup.cpp
search_SOURCES = search.cpp
@@ -14,5 +14,6 @@
verserangeparse_SOURCES = verserangeparse.cpp
threaded_search_SOURCES = threaded_search.cpp
outplain_SOURCES = outplain.cpp
+outvplskeleton_SOURCES = outvplskeleton.cpp
outrender_SOURCES = outrender.cpp
threaded_search_LDADD = $(LDADD) -lpthread
Added: trunk/examples/cmdline/outvplskeleton.cpp
===================================================================
--- trunk/examples/cmdline/outvplskeleton.cpp (rev 0)
+++ trunk/examples/cmdline/outvplskeleton.cpp 2018-11-12 20:14:12 UTC (rev 3608)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ *
+ * outvplskeleton.cpp -This example shows how to output a skeleton of
+ * verse references from a SWORD module.
+ *
+ * Gen.1.1
+ * Gen.1.2
+ * ...
+ *
+ * Class SWMgr manages installed modules for a frontend.
+ * The developer may use this class to query what modules are installed
+ * and to retrieve an (SWModule *) for any one of these modules
+ *
+ * SWMgr makes its modules available as an STL Map.
+ * The Map definition is typedef'ed as ModMap
+ * ModMap consists of: FIRST : SWBuf moduleName
+ * SECOND: SWModule *module
+ *
+ * $Id: outvplskeleton.cpp Refdoc $
+ *
+ * Copyright 2008-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 <iostream>
+
+#include <swmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+#include <markupfiltmgr.h>
+
+
+using namespace sword;
+using namespace std;
+
+
+int main(int argc, char **argv) {
+
+ SWMgr manager(new MarkupFilterMgr(sword::FMT_XHTML, sword::ENC_UTF8));
+
+ const char *bookName = (argc > 1) ? argv[1] : "KJV";
+ SWModule *b = manager.getModule(bookName);
+ if (!b) return -1;
+ SWModule &book = *b;
+ book.setProcessEntryAttributes(false);
+ VerseKey *vk = SWDYNAMIC_CAST(VerseKey, book.getKey());
+ for (book = TOP; !book.popError() && !book.getRawEntryBuf().size(); book++);
+ if (!book.getRawEntryBuf().size()) return -2; // empty module
+ for (;!book.popError(); book++) {
+ if (vk) cout << vk->getOSISRef();
+ else cout << book.getKeyText();
+ cout << "\n";
+ }
+
+ return 0;
+}
More information about the sword-cvs
mailing list