[sword-svn] r3847 - in trunk/examples: classes tasks
scribe at crosswire.org
scribe at crosswire.org
Thu Feb 25 16:30:13 EST 2021
Author: scribe
Date: 2021-02-25 16:30:13 -0500 (Thu, 25 Feb 2021)
New Revision: 3847
Added:
trunk/examples/tasks/Makefile
trunk/examples/tasks/listExtantModuleBookNames.cpp
trunk/examples/tasks/parallelBibles.cpp
trunk/examples/tasks/simpleChapter.cpp
trunk/examples/tasks/simpleRange.cpp
trunk/examples/tasks/simpleVerseLookup.cpp
Removed:
trunk/examples/classes/simplechapter.cpp
trunk/examples/tasks/Makefile.am
trunk/examples/tasks/listbiblebooknames.cpp
trunk/examples/tasks/parallelbibles.cpp
trunk/examples/tasks/simpleverselookup.cpp
Modified:
trunk/examples/classes/Makefile
trunk/examples/tasks/CMakeLists.txt
Log:
reworked the naming and comments of some of the examples
better simple Makefile which doesn't require listing each example
added simpleRange.cpp example
Modified: trunk/examples/classes/Makefile
===================================================================
--- trunk/examples/classes/Makefile 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/classes/Makefile 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,8 +1,12 @@
-TARGETS= ciphercng swmgrex verseranges versevalid lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch versenorm flatapiinstallmgr verseconvert
+CPP_SRCS=$(wildcard *.cpp)
+C_SRCS=$(wildcard *.c)
+
+TARGETS=$(patsubst %.c,%,$(C_SRCS)) $(patsubst %.cpp,%,$(CPP_SRCS))
+
all: $(TARGETS)
clean:
- rm $(TARGETS)
+ rm -f $(TARGETS)
.cpp:
g++ -O0 -g -Wall -Werror `pkg-config --cflags sword` $< -o $@ `pkg-config --libs sword`
Deleted: trunk/examples/classes/simplechapter.cpp
===================================================================
--- trunk/examples/classes/simplechapter.cpp 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/classes/simplechapter.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,61 +0,0 @@
-/******************************************************************************
- *
- * simplechapter.cpp - this example shows how to display the entire chapter
- * of a given verse, marking the given verse within the chapter.
- * This example is very simple and doesn't set output markup or take into
- * account interverse material like chapter intros and section headings.
- * For a more complete example, see ../tasks/parallelbibles.cpp
- *
- * $Id$
- *
- * Copyright 2013-2014 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 <swmgr.h>
-#include <swmodule.h>
-#include <versekey.h>
-#include <iostream>
-
-
-using namespace sword;
-using namespace std;
-
-
-int main(int argc, char **argv) {
-
- SWMgr library;
- SWModule *kjv = library.getModule((argc > 1)?argv[1]:"KJV");
-
- kjv->setKey(argc > 2 ? argv[2] : "Jn.3.16");
-
- VerseKey *key = (VerseKey *)kjv->getKey();
-
- int curVerse = key->getVerse();
- int curChapter = key->getChapter();
- int curBook = key->getBook();
-
- for (key->setVerse(1);
- (key->getBook() == curBook) &&
- (key->getChapter() == curChapter) &&
- !kjv->popError();
- (*kjv)++) {
- if (key->getVerse() == curVerse) cout << "* ";
- cout << key->getVerse() << " " << kjv->stripText() << "\n";
- }
-
- return 0;
-}
-
Modified: trunk/examples/tasks/CMakeLists.txt
===================================================================
--- trunk/examples/tasks/CMakeLists.txt 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/tasks/CMakeLists.txt 2021-02-25 21:30:13 UTC (rev 3847)
@@ -5,9 +5,11 @@
#
MESSAGE(STATUS "\n-- CONFIGURING LIBRARY EXAMPLES")
SET(example_PROGRAMS
- parallelbibles
- simpleverselookup
- listbiblebooknames
+ parallelBibles
+ simpleVerseLookup
+ simpleChapter
+ simpleRange
+ listExtantModuleBookNames
)
FOREACH(DEMO ${example_PROGRAMS})
Added: trunk/examples/tasks/Makefile
===================================================================
--- trunk/examples/tasks/Makefile (rev 0)
+++ trunk/examples/tasks/Makefile 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,15 @@
+SRCS=$(wildcard *.cpp)
+
+TARGETS=$(patsubst %.cpp,%,$(SRCS))
+
+all: $(TARGETS)
+
+clean:
+ rm -f $(TARGETS)
+
+.cpp:
+ g++ -O0 -g -Wall -Werror `pkg-config --cflags sword` $< -o $@ `pkg-config --libs sword`
+.c:
+ gcc -O0 -g -Wall -Werror `pkg-config --cflags sword` $< -o $@ `pkg-config --libs sword` -lstdc++
+
+
Deleted: trunk/examples/tasks/Makefile.am
===================================================================
--- trunk/examples/tasks/Makefile.am 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/tasks/Makefile.am 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,16 +0,0 @@
-AUTOMAKE_OPTIONS = 1.6
-AM_CPPFLAGS = -I $(top_srcdir)/include
-if USE_INTERNAL_REGEX
-AM_CPPFLAGS += -I$(top_srcdir)/include/internal/regex
-endif
-LDADD = $(top_builddir)/lib/libsword.la
-
-noinst_PROGRAMS = parallelbibles listbiblebooknames simpleverselookup
-
-parallelbibles_SOURCES = parallelbibles.cpp
-listbiblebooknames_SOURCES = listbiblebooknames.cpp
-simpleverselookup_SOURCES = simpleverselookup.cpp
-
-distclean-local:
- -rm -f Makefile.in
-
\ No newline at end of file
Copied: trunk/examples/tasks/listExtantModuleBookNames.cpp (from rev 3846, trunk/examples/tasks/listbiblebooknames.cpp)
===================================================================
--- trunk/examples/tasks/listExtantModuleBookNames.cpp (rev 0)
+++ trunk/examples/tasks/listExtantModuleBookNames.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ *
+ * listExtantModuleBookNames.cpp - This example demonstrates how to list
+ * book names available within a module
+ *
+ * $Id$
+ *
+ * Copyright 2011-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>
+
+
+using namespace sword;
+using namespace std;
+
+
+int main(int argc, char **argv) {
+
+ cout << "\n";
+
+ const char *modName = (argc > 1) ? argv[1] : "KJV";
+ SWMgr manager;
+ SWModule *bible = manager.getModule(modName);
+ if (!bible) {
+ cout << modName << " module is not installed.\nPlease install to show versification (v11n) from this specific Bible.\nShowing builtin KJV v11n scheme..\n\n";
+ }
+
+ VerseKey *vk = (bible) ? (VerseKey *)bible->getKey() : new VerseKey();
+
+ for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook()+1)) {
+ if (!bible || bible->hasEntry(vk)) {
+ cout << vk->getBookName() << "\n";
+ }
+ }
+
+ // if we 'new'ed a VerseKey unassociated with a module, above, then we should delete it.
+ if (!bible) delete vk;
+
+ return 0;
+}
+
Deleted: trunk/examples/tasks/listbiblebooknames.cpp
===================================================================
--- trunk/examples/tasks/listbiblebooknames.cpp 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/tasks/listbiblebooknames.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,59 +0,0 @@
-/******************************************************************************
- *
- * verseranges.cpp - This example demonstrates how to work with contiguous
- * verse ranges using VerseKey
- *
- * $Id$
- *
- * Copyright 2011-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>
-
-
-using namespace sword;
-using namespace std;
-
-
-int main(int argc, char **argv) {
-
- cout << "\n";
-
- const char *modName = (argc > 1) ? argv[1] : "KJV";
- SWMgr manager;
- SWModule *bible = manager.getModule(modName);
- if (!bible) {
- cout << modName << " module is not installed.\nPlease install to show versification (v11n) from this specific Bible.\nShowing builtin KJV v11n scheme..\n\n";
- }
-
- VerseKey *vk = (bible) ? (VerseKey *)bible->getKey() : new VerseKey();
-
- for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook()+1)) {
- if (!bible || bible->hasEntry(vk)) {
- cout << vk->getBookName() << "\n";
- }
- }
-
- // if we 'new'ed a VerseKey unassociated with a module, above, then we should delete it.
- if (!bible) delete vk;
-
- return 0;
-}
-
Copied: trunk/examples/tasks/parallelBibles.cpp (from rev 3846, trunk/examples/tasks/parallelbibles.cpp)
===================================================================
--- trunk/examples/tasks/parallelBibles.cpp (rev 0)
+++ trunk/examples/tasks/parallelBibles.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,237 @@
+/******************************************************************************
+ *
+ * parallelBibles.cpp - This examples demonstrates a strategy for
+ * displaying Bibles in parallel
+ *
+ * $Id: parallelbibles.cpp 3030 2014-02-28 02:14:44Z scribe $
+ *
+ * Copyright 2013-2014 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 <swmgr.h>
+#include <markupfiltmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+#include <iostream>
+#include <vector>
+#include <stdio.h>
+
+
+using namespace sword;
+using namespace std;
+
+const bool o = 1;
+
+void parallelDisplay(vector<SWModule *>modules, const char *key) {
+
+ //cout << "Start key:" << key;
+
+ // We'll use the first module's key as our master key to position all other modules.
+ VerseKey *master = (VerseKey *)modules[0]->createKey();
+
+ master->setText(key);
+
+ //cout << "\t key:" << master->getText();
+
+ int curVerse = master->getVerse();
+ int curChapter = master->getChapter();
+ int curBook = master->getBook();
+
+ for (master->setVerse(1); (master->getBook() == curBook)
+ && (master->getChapter() == curChapter)
+ && !master->popError();
+ (*master)++) {
+
+ if(o) cout << "<tr class=\"" << (master->getVerse() == curVerse ? "currentverse":"verse") << "\">";
+
+ for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
+ //cout << "\n\n====================\nfromKey" << master->getOSISRef();
+
+ (*module)->setKey(master);
+ VerseKey slave((*module)->getKey());
+
+ //cout << "setKey" << (*module)->getName() << slave.getBookName() << slave.getRangeText() << slave.getShortText();
+
+ if(o) cout << "<td>" << "<span class=\"versenum\">";
+
+ //cout << "[" << (int)slave.getBook() << " " << (int)master->getBook() << " " << (int)slave.getTestament() << " " << (int)master->getTestament() << "]";
+
+
+ if (!(*module)->popError()) {
+
+ if(strcmp(slave.getBookName(), master->getBookName())) {
+ if(o) cout << slave.getShortText();
+ }
+ else if(slave.getChapter() != master->getChapter()) {
+ if(o) cout << slave.getChapter() << ":" << slave.getVerse();
+ }
+ else {
+ if(o) cout << slave.getVerse();
+ }
+
+ if(slave.isBoundSet()) {
+ if(o) cout << "-";
+ if(slave.getUpperBound().getBook() != slave.getLowerBound().getBook()) {
+ if(o) cout << slave.getUpperBound().getShortText();
+ }
+ else if(slave.getUpperBound().getChapter() != slave.getLowerBound().getChapter()) {
+ if(o) cout << slave.getUpperBound().getChapter() << ":" << slave.getUpperBound().getVerse();
+ }
+ else {
+ if(o) cout << slave.getUpperBound().getVerse();
+ }
+ }
+
+ if(o) cout << "</span> ";
+
+
+ if(slave.isBoundSet()) {
+ VerseKey temp(slave);
+ for(int i = slave.getLowerBound().getIndex(); i <= slave.getUpperBound().getIndex(); ++i) {
+ if(i > 0) if(o) cout << " ";
+ temp.setIndex(i);
+ (*module)->setKey(temp);
+ if(o) cout << (*module)->renderText();
+ }
+ }
+ else {
+ if(o) cout << (*module)->renderText();
+ }
+
+ if(o) cout << "</td>";
+ }
+ }
+ if(o) cout << "</tr>";
+ }
+ delete master;
+}
+
+
+void outputHeader(vector<SWModule *>modules, const char *key) {
+
+ modules[0]->setKey(key);
+
+ // force a render so our key snaps to a module entry and we get nicely formatted keytext output later
+ // otherwise we just get what the user typed
+ modules[0]->renderText();
+
+ cout
+ << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
+ << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://ogp.me/ns#\" xmlns:fb=\"https://www.facebook.com/2008/fbml\" xml:lang=\"en_US\" lang=\"en_US\">"
+ << "<head profile=\"http://www.w3.org/2000/08/w3c-synd/#\">"
+ << "<meta name=\"keywords\" content=\"Jesus, Christ, Church, Bible, Iran, Persian, Persia, Azeri, Azerbaijan, Armenian, God, Gospel, CrossWire, Java, Web, Software\" />"
+ << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
+ << "<title>OSIS Web: " << modules[0]->getKeyText() << " - Parallel Bible study</title>"
+ << "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"http://crosswire.org/study/common.css\" />"
+ << "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" title=\"Washed Out\" href=\"http://crosswire.org/study/wash.css\" />"
+ << "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css\"/>"
+ << "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js\"></script>"
+ << "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js\"></script>"
+ << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Washed Out\" href=\"http://crosswire.org/study/wash.css\" />"
+ << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Parchment\" href=\"http://crosswire.org/study/parchment.css\" />"
+ << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Sandy Creek\" href=\"http://crosswire.org/study/sandy.css\" />"
+ << "<!--For printing stuff -->"
+ << "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"http://crosswire.org/study/print.css\" />"
+ << "<script type=\"text/javascript\" src=\"http://crosswire.org/study/swordweb.js\"></script>"
+ << "</head>"
+ << "<body onload=\"onPageLoad();\" class=\"ltor\">"
+ << "<div id=\"pageBorderTop\"></div>"
+ << "<div id=\"header\">"
+ << "<h1>The Bible Tool</h1>"
+ << "</div>"
+ << "<div id=\"content-main\">"
+ << "<div id=\"paralleldisplay\">"
+ << "<style>"
+ << modules[0]->getRenderHeader()
+ << "</style>"
+ << "<h2>Parallel Viewing: " << modules[0]->getKeyText() << "</h2><br/>"
+ << "<table><thead><tr>";
+
+ for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
+ cout << "<th>" << (*module)->getDescription() << "</th>";
+ }
+
+ cout
+ << "</tr></thead><tbody>";
+
+
+}
+
+void outputFooter(vector<SWModule *>modules) {
+
+ cout
+ << "</tbody><tfoot><tr>";
+
+ for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
+ SWBuf copyLine = (*module)->getConfigEntry("ShortCopyright");
+ SWBuf promoLine = (*module)->getConfigEntry("ShortPromo");
+ cout
+ << "<th>"
+ << "<div class=\"copyLine\">" << copyLine << "</div>"
+ << "<div class=\"promoLine\">" << promoLine << "</div>"
+ << "</th>";
+ }
+
+ cout
+ << "</tr></tfoot></table>"
+ << "</div>"
+ << "</div>"
+ << "<div id=\"footer\">"
+ << "<p>"
+ << "<a href=\"http://www.americanbible.org/\" title=\"American Bible Society\"><img src=\"http://crosswire.org/study/images/logo_abs.gif\" width=\"105\" height=\"64\" alt=\"American Bible Society\" /></a>"
+ << "<a href=\"http://crosswire.org/\" title=\"CrossWire Bible Society\"><img src=\"http://crosswire.org/study/images/logo_cwbs.gif\" width=\"161\" height=\"64\" alt=\"CrossWire Bible Society\" /></a>"
+ << "<a href=\"http://sbl-site.org/\" title=\"Society of Biblical Literature\"><img src=\"http://crosswire.org/study/images/logo_fbl.gif\" width=\"86\" height=\"64\" alt=\"Society of Biblical Literature\" /></a>"
+ << "</p>"
+ << "<p>Copyright © 2003-2011 <a href=\"http://www.crosswire.org/\">CrossWire Bible Society</a></p>"
+ << "<div id=\"pageBorderBottom\"><br /></div>"
+ << "</div>"
+ << "</body>"
+ << "</html>";
+}
+
+
+int main(int argc, char **argv) {
+
+ SWMgr library(new MarkupFilterMgr(FMT_XHTML));
+
+ if (argc < 3) {
+ fprintf(stderr, "\nusage: %s <modname> [modname ...] <\"key\">\n"
+ "\tExample: %s KJV ESV \"James 1:19\"\n\n", argv[0], argv[0]);
+ exit(-1);
+ }
+
+ vector<SWModule *> modules;
+ for (int i = 1; i < argc-1; ++i) {
+ SWModule *bible = library.getModule(argv[i]);
+ if (!bible) {
+ fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[i]);
+ ModMap::iterator it;
+ for (it = library.Modules.begin(); it != library.Modules.end(); ++it) {
+ fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription());
+ }
+ exit(-2);
+ }
+ modules.push_back(bible);
+ }
+
+ if(o) outputHeader(modules, argv[argc-1]);
+ parallelDisplay(modules, argv[argc-1]);
+ if(o) outputFooter(modules);
+
+ return 0;
+}
+
Deleted: trunk/examples/tasks/parallelbibles.cpp
===================================================================
--- trunk/examples/tasks/parallelbibles.cpp 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/tasks/parallelbibles.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,237 +0,0 @@
-/******************************************************************************
- *
- * parallelbibles.cpp - This examples demonstrates a strategy for
- * displaying Bibles in parallel
- *
- * $Id: parallelbibles.cpp 3030 2014-02-28 02:14:44Z scribe $
- *
- * Copyright 2013-2014 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 <swmgr.h>
-#include <markupfiltmgr.h>
-#include <swmodule.h>
-#include <versekey.h>
-#include <iostream>
-#include <vector>
-#include <stdio.h>
-
-
-using namespace sword;
-using namespace std;
-
-const bool o = 1;
-
-void parallelDisplay(vector<SWModule *>modules, const char *key) {
-
- //cout << "Start key:" << key;
-
- // We'll use the first module's key as our master key to position all other modules.
- VerseKey *master = (VerseKey *)modules[0]->createKey();
-
- master->setText(key);
-
- //cout << "\t key:" << master->getText();
-
- int curVerse = master->getVerse();
- int curChapter = master->getChapter();
- int curBook = master->getBook();
-
- for (master->setVerse(1); (master->getBook() == curBook)
- && (master->getChapter() == curChapter)
- && !master->popError();
- (*master)++) {
-
- if(o) cout << "<tr class=\"" << (master->getVerse() == curVerse ? "currentverse":"verse") << "\">";
-
- for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
- //cout << "\n\n====================\nfromKey" << master->getOSISRef();
-
- (*module)->setKey(master);
- VerseKey slave((*module)->getKey());
-
- //cout << "setKey" << (*module)->getName() << slave.getBookName() << slave.getRangeText() << slave.getShortText();
-
- if(o) cout << "<td>" << "<span class=\"versenum\">";
-
- //cout << "[" << (int)slave.getBook() << " " << (int)master->getBook() << " " << (int)slave.getTestament() << " " << (int)master->getTestament() << "]";
-
-
- if (!(*module)->popError()) {
-
- if(strcmp(slave.getBookName(), master->getBookName())) {
- if(o) cout << slave.getShortText();
- }
- else if(slave.getChapter() != master->getChapter()) {
- if(o) cout << slave.getChapter() << ":" << slave.getVerse();
- }
- else {
- if(o) cout << slave.getVerse();
- }
-
- if(slave.isBoundSet()) {
- if(o) cout << "-";
- if(slave.getUpperBound().getBook() != slave.getLowerBound().getBook()) {
- if(o) cout << slave.getUpperBound().getShortText();
- }
- else if(slave.getUpperBound().getChapter() != slave.getLowerBound().getChapter()) {
- if(o) cout << slave.getUpperBound().getChapter() << ":" << slave.getUpperBound().getVerse();
- }
- else {
- if(o) cout << slave.getUpperBound().getVerse();
- }
- }
-
- if(o) cout << "</span> ";
-
-
- if(slave.isBoundSet()) {
- VerseKey temp(slave);
- for(int i = slave.getLowerBound().getIndex(); i <= slave.getUpperBound().getIndex(); ++i) {
- if(i > 0) if(o) cout << " ";
- temp.setIndex(i);
- (*module)->setKey(temp);
- if(o) cout << (*module)->renderText();
- }
- }
- else {
- if(o) cout << (*module)->renderText();
- }
-
- if(o) cout << "</td>";
- }
- }
- if(o) cout << "</tr>";
- }
- delete master;
-}
-
-
-void outputHeader(vector<SWModule *>modules, const char *key) {
-
- modules[0]->setKey(key);
-
- // force a render so our key snaps to a module entry and we get nicely formatted keytext output later
- // otherwise we just get what the user typed
- modules[0]->renderText();
-
- cout
- << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
- << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://ogp.me/ns#\" xmlns:fb=\"https://www.facebook.com/2008/fbml\" xml:lang=\"en_US\" lang=\"en_US\">"
- << "<head profile=\"http://www.w3.org/2000/08/w3c-synd/#\">"
- << "<meta name=\"keywords\" content=\"Jesus, Christ, Church, Bible, Iran, Persian, Persia, Azeri, Azerbaijan, Armenian, God, Gospel, CrossWire, Java, Web, Software\" />"
- << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- << "<title>OSIS Web: " << modules[0]->getKeyText() << " - Parallel Bible study</title>"
- << "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"http://crosswire.org/study/common.css\" />"
- << "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" title=\"Washed Out\" href=\"http://crosswire.org/study/wash.css\" />"
- << "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css\"/>"
- << "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js\"></script>"
- << "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js\"></script>"
- << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Washed Out\" href=\"http://crosswire.org/study/wash.css\" />"
- << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Parchment\" href=\"http://crosswire.org/study/parchment.css\" />"
- << "<link rel=\"alternate stylesheet\" type=\"text/css\" media=\"all\" title=\"Sandy Creek\" href=\"http://crosswire.org/study/sandy.css\" />"
- << "<!--For printing stuff -->"
- << "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"http://crosswire.org/study/print.css\" />"
- << "<script type=\"text/javascript\" src=\"http://crosswire.org/study/swordweb.js\"></script>"
- << "</head>"
- << "<body onload=\"onPageLoad();\" class=\"ltor\">"
- << "<div id=\"pageBorderTop\"></div>"
- << "<div id=\"header\">"
- << "<h1>The Bible Tool</h1>"
- << "</div>"
- << "<div id=\"content-main\">"
- << "<div id=\"paralleldisplay\">"
- << "<style>"
- << modules[0]->getRenderHeader()
- << "</style>"
- << "<h2>Parallel Viewing: " << modules[0]->getKeyText() << "</h2><br/>"
- << "<table><thead><tr>";
-
- for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
- cout << "<th>" << (*module)->getDescription() << "</th>";
- }
-
- cout
- << "</tr></thead><tbody>";
-
-
-}
-
-void outputFooter(vector<SWModule *>modules) {
-
- cout
- << "</tbody><tfoot><tr>";
-
- for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) {
- SWBuf copyLine = (*module)->getConfigEntry("ShortCopyright");
- SWBuf promoLine = (*module)->getConfigEntry("ShortPromo");
- cout
- << "<th>"
- << "<div class=\"copyLine\">" << copyLine << "</div>"
- << "<div class=\"promoLine\">" << promoLine << "</div>"
- << "</th>";
- }
-
- cout
- << "</tr></tfoot></table>"
- << "</div>"
- << "</div>"
- << "<div id=\"footer\">"
- << "<p>"
- << "<a href=\"http://www.americanbible.org/\" title=\"American Bible Society\"><img src=\"http://crosswire.org/study/images/logo_abs.gif\" width=\"105\" height=\"64\" alt=\"American Bible Society\" /></a>"
- << "<a href=\"http://crosswire.org/\" title=\"CrossWire Bible Society\"><img src=\"http://crosswire.org/study/images/logo_cwbs.gif\" width=\"161\" height=\"64\" alt=\"CrossWire Bible Society\" /></a>"
- << "<a href=\"http://sbl-site.org/\" title=\"Society of Biblical Literature\"><img src=\"http://crosswire.org/study/images/logo_fbl.gif\" width=\"86\" height=\"64\" alt=\"Society of Biblical Literature\" /></a>"
- << "</p>"
- << "<p>Copyright © 2003-2011 <a href=\"http://www.crosswire.org/\">CrossWire Bible Society</a></p>"
- << "<div id=\"pageBorderBottom\"><br /></div>"
- << "</div>"
- << "</body>"
- << "</html>";
-}
-
-
-int main(int argc, char **argv) {
-
- SWMgr library(new MarkupFilterMgr(FMT_XHTML));
-
- if (argc < 3) {
- fprintf(stderr, "\nusage: %s <modname> [modname ...] <\"key\">\n"
- "\tExample: %s KJV ESV \"James 1:19\"\n\n", argv[0], argv[0]);
- exit(-1);
- }
-
- vector<SWModule *> modules;
- for (int i = 1; i < argc-1; ++i) {
- SWModule *bible = library.getModule(argv[i]);
- if (!bible) {
- fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[i]);
- ModMap::iterator it;
- for (it = library.Modules.begin(); it != library.Modules.end(); ++it) {
- fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription());
- }
- exit(-2);
- }
- modules.push_back(bible);
- }
-
- if(o) outputHeader(modules, argv[argc-1]);
- parallelDisplay(modules, argv[argc-1]);
- if(o) outputFooter(modules);
-
- return 0;
-}
-
Copied: trunk/examples/tasks/simpleChapter.cpp (from rev 3846, trunk/examples/classes/simplechapter.cpp)
===================================================================
--- trunk/examples/tasks/simpleChapter.cpp (rev 0)
+++ trunk/examples/tasks/simpleChapter.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ * simpleChapter.cpp - this example shows how to display the entire chapter
+ * of a given verse, marking the given verse within the chapter.
+ * This example is very simple and doesn't set output markup or take into
+ * account interverse material like chapter intros and section headings.
+ * For a more complete example, see ../tasks/parallelbibles.cpp
+ *
+ * $Id$
+ *
+ * Copyright 2013-2014 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 <swmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+#include <iostream>
+
+
+using namespace sword;
+using namespace std;
+
+
+int main(int argc, char **argv) {
+
+ SWMgr library;
+ SWModule *kjv = library.getModule((argc > 1)?argv[1]:"KJV");
+
+ kjv->setKey(argc > 2 ? argv[2] : "Jn.3.16");
+
+ VerseKey *key = (VerseKey *)kjv->getKey();
+
+ int curVerse = key->getVerse();
+ int curChapter = key->getChapter();
+ int curBook = key->getBook();
+
+ for (key->setVerse(1);
+ (key->getBook() == curBook) &&
+ (key->getChapter() == curChapter) &&
+ !kjv->popError();
+ (*kjv)++) {
+ if (key->getVerse() == curVerse) cout << "* ";
+ cout << key->getVerse() << " " << kjv->stripText() << "\n";
+ }
+
+ return 0;
+}
+
Added: trunk/examples/tasks/simpleRange.cpp
===================================================================
--- trunk/examples/tasks/simpleRange.cpp (rev 0)
+++ trunk/examples/tasks/simpleRange.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ *
+ * simpleRange.cpp - this example shows how to display Bible text specified
+ * by a verse range
+ *
+ * $Id: simplechapter.cpp 3732 2020-05-06 16:07:19Z scribe $
+ *
+ * Copyright 2013-2014 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 <markupfiltmgr.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+using namespace sword;
+using namespace std;
+
+
+int main(int argc, char **argv) {
+
+ SWBuf moduleName = argc > 1 ? argv[1] : "KJV";
+ SWBuf verseRange = argc > 2 ? argv[2] : "jn.2.19-3.2";
+
+ SWMgr library(new MarkupFilterMgr(FMT_XHTML));
+ SWModule *module = library.getModule(moduleName);
+
+ if (!module) return cerr << "\nCouldn't find module: " << moduleName << "\n\n", -1;
+
+ VerseKey parser = module->getKey();
+ ListKey range = parser.parseVerseList(verseRange, parser, true);
+
+ cout << "\n" << module->getDescription() << " -- " << range.getRangeText();
+ cout << "\n-------------------\n";
+ cout << "<style>\n" << module->getRenderHeader() << "\n</style>\n\n";
+ for (range = TOP; !range.popError(); range++) {
+ module->setKey(range);
+ SWBuf key = module->getKey()->getText();
+ SWBuf entry = module->renderText();
+ cout << key << ": " << entry << "\n";
+ }
+ cout << "\n";
+ return 0;
+}
Copied: trunk/examples/tasks/simpleVerseLookup.cpp (from rev 3846, trunk/examples/tasks/simpleverselookup.cpp)
===================================================================
--- trunk/examples/tasks/simpleVerseLookup.cpp (rev 0)
+++ trunk/examples/tasks/simpleVerseLookup.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ *
+ * simpleVerseLookup.cpp - This is about the simplest useful example of
+ * using the SWORD engine.
+ *
+ * After sword is installed, it should compile with something similar to:
+ *
+ * g++ -o simple simple.cpp `pkg-config --cflags --libs sword`
+ *
+ * If you'd like to choose the type of tag markup which sword will output
+ * for you, include:
+ *
+ * #include <markupfiltmgr.h>
+ *
+ * and change your instantiation of SWMgr, below, to (e.g., for HTML):
+ *
+ * SWMgr library(0, 0, true, new MarkupFilterMgr(FMT_HTMLHREF));
+ *
+ * $Id$
+ *
+ * Copyright 2006-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.
+ *
+ */
+
+// Simple example to show James 1:19 from KJV,
+// if argv[1] is passed then use this instead of KJV
+// if argv[2] is passed then use this instead of James 1:19
+
+#include <swmgr.h>
+#include <swmodule.h>
+#include <iostream>
+
+
+using namespace sword;
+using std::cout;
+
+
+int main(int argc, char **argv) {
+ // instantiate a SWORD Manager to give access to the installed library of books (modules)
+ SWMgr library;
+
+ // try to retrieve a reference to an installed book (module)
+ SWModule *book = library.getModule((argc > 1) ? argv[1] : "KJV");
+
+ // set that book's reference key to our desired verse
+ book->setKey((argc > 2) ? argv[2] : "James 1:19");
+
+ // ask the book to render the current text
+ cout << book->renderText() << "\n";
+
+ return 0;
+}
+
Deleted: trunk/examples/tasks/simpleverselookup.cpp
===================================================================
--- trunk/examples/tasks/simpleverselookup.cpp 2021-02-24 21:04:04 UTC (rev 3846)
+++ trunk/examples/tasks/simpleverselookup.cpp 2021-02-25 21:30:13 UTC (rev 3847)
@@ -1,65 +0,0 @@
-/******************************************************************************
- *
- * simple.cpp - This is about the simplest useful example of using the
- * SWORD engine.
- *
- * After sword is installed, it should compile with something similar to:
- *
- * g++ -o simple simple.cpp `pkg-config --cflags --libs sword`
- *
- * If you'd like to choose the type of tag markup which sword will output
- * for you, include:
- *
- * #include <markupfiltmgr.h>
- *
- * and change your instantiation of SWMgr, below, to (e.g., for HTML):
- *
- * SWMgr library(0, 0, true, new MarkupFilterMgr(FMT_HTMLHREF));
- *
- * $Id$
- *
- * Copyright 2006-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.
- *
- */
-
-// Simple example to show James 1:19 from KJV,
-// if argv[1] is passed then use this instead of KJV
-// if argv[2] is passed then use this instead of James 1:19
-
-#include <swmgr.h>
-#include <swmodule.h>
-#include <iostream>
-
-
-using namespace sword;
-using std::cout;
-
-
-int main(int argc, char **argv) {
- // instantiate a SWORD Manager to give access to the installed library of books (modules)
- SWMgr library;
-
- // try to retrieve a reference to an installed book (module)
- SWModule *book = library.getModule((argc > 1) ? argv[1] : "KJV");
-
- // set that book's reference key to our desired verse
- book->setKey((argc > 2) ? argv[2] : "James 1:19");
-
- // ask the book to render the current text
- cout << book->renderText() << "\n";
-
- return 0;
-}
-
More information about the sword-cvs
mailing list