From d5be8eb6b5193a123cbc87ac86bb0a923967e79b Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Sat, 10 Nov 2018 20:58:48 +0700 Subject: Import sword_1.8.1+dfsg.orig.tar.gz [dgit import orig sword_1.8.1+dfsg.orig.tar.gz] --- examples/classes/Makefile | 12 +++ examples/classes/README | 4 + examples/classes/ciphercng.cpp | 69 +++++++++++++++++ examples/classes/flatapiinstallmgr.cpp | 48 ++++++++++++ examples/classes/flatapilookup.c | 63 ++++++++++++++++ examples/classes/flatapiparsekey.c | 65 ++++++++++++++++ examples/classes/flatapisearch.c | 66 +++++++++++++++++ examples/classes/lastVerseInChapter.cpp | 56 ++++++++++++++ examples/classes/simplechapter.cpp | 57 ++++++++++++++ examples/classes/swmgrex.cpp | 78 ++++++++++++++++++++ examples/classes/versenorm.cpp | 72 ++++++++++++++++++ examples/classes/verseposition.cpp | 51 +++++++++++++ examples/classes/verseranges.cpp | 127 ++++++++++++++++++++++++++++++++ 13 files changed, 768 insertions(+) create mode 100644 examples/classes/Makefile create mode 100644 examples/classes/README create mode 100644 examples/classes/ciphercng.cpp create mode 100644 examples/classes/flatapiinstallmgr.cpp create mode 100644 examples/classes/flatapilookup.c create mode 100644 examples/classes/flatapiparsekey.c create mode 100644 examples/classes/flatapisearch.c create mode 100644 examples/classes/lastVerseInChapter.cpp create mode 100644 examples/classes/simplechapter.cpp create mode 100644 examples/classes/swmgrex.cpp create mode 100644 examples/classes/versenorm.cpp create mode 100644 examples/classes/verseposition.cpp create mode 100644 examples/classes/verseranges.cpp (limited to 'examples/classes') diff --git a/examples/classes/Makefile b/examples/classes/Makefile new file mode 100644 index 0000000..04e3457 --- /dev/null +++ b/examples/classes/Makefile @@ -0,0 +1,12 @@ +TARGETS= ciphercng swmgrex verseranges lastVerseInChapter verseposition simplechapter flatapilookup flatapiparsekey flatapisearch versenorm flatapiinstallmgr +all: $(TARGETS) + +clean: + rm $(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++ + + diff --git a/examples/classes/README b/examples/classes/README new file mode 100644 index 0000000..53a65b7 --- /dev/null +++ b/examples/classes/README @@ -0,0 +1,4 @@ +These examples use a standard Makefile which exemplifies how you can compile +your own code against the SWORD engine. +This does, however, require SWORD to be installed before a 'make' in this +folder will be successful. diff --git a/examples/classes/ciphercng.cpp b/examples/classes/ciphercng.cpp new file mode 100644 index 0000000..f1ce5e8 --- /dev/null +++ b/examples/classes/ciphercng.cpp @@ -0,0 +1,69 @@ +/****************************************************************************** + * + * ciphercng.cpp - This example demonstrates how to change the cipher key + * of a module. The change is only in effect for this + * run. This DOES NOT change the cipherkey in the + * module's .conf file. + * + * $Id: ciphercng.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 2000-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 +#include + +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + if (argc != 2) { + fprintf(stderr, "usage: %s \n", *argv); + exit(-1); + } + + SWMgr manager; // create a default manager that looks in the current directory for mods.conf + ModMap::iterator it; + it = manager.Modules.find(argv[1]); + + if (it == manager.Modules.end()) { + fprintf(stderr, "%s: couldn't find module: %s\n", *argv, argv[1]); + exit(-1); + } + + SWModule *module = (*it).second; + string key; + + cout << "\nPress [CTRL-C] to end\n\n"; + while (true) { + cout << "\nModule text:\n"; + module->setKey("1jn 1:9"); + cout << "[ " << module->getKeyText() << " ]\n"; + cout << module->renderText(); + cout << "\n\nEnter new cipher key: "; + cin >> key; + cout << "\nSetting key to: " << key; + manager.setCipherKey(argv[1], key.c_str()); + } + + return 0; +} diff --git a/examples/classes/flatapiinstallmgr.cpp b/examples/classes/flatapiinstallmgr.cpp new file mode 100644 index 0000000..6541063 --- /dev/null +++ b/examples/classes/flatapiinstallmgr.cpp @@ -0,0 +1,48 @@ +/****************************************************************************** + * + * flatapilookup.c - + * + * $Id$ + * + * Copyright 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 +#include + +#include + +int main(int argc, char **argv) { + if (argc != 4) { + fprintf(stderr, "\nusage: %s \"\" <\"modName\"> \"\"\n" + "\tExample: CrossWire KJV ~/library\n\n", argv[0]); + exit(-1); + } + + + SWHANDLE mgr = org_crosswire_sword_SWMgr_newWithPath(argv[3]); + + SWHANDLE instMgr = org_crosswire_sword_InstallMgr_new("/home/scribe/.sword/InstallMgr", 0); + + org_crosswire_sword_InstallMgr_setUserDisclaimerConfirmed(instMgr); + + fprintf(stdout, "Install returned: %d\n", org_crosswire_sword_InstallMgr_remoteInstallModule(instMgr, mgr, argv[1], argv[2])); + + org_crosswire_sword_SWMgr_delete(mgr); + org_crosswire_sword_InstallMgr_delete(instMgr); + + return 0; +} diff --git a/examples/classes/flatapilookup.c b/examples/classes/flatapilookup.c new file mode 100644 index 0000000..9afde22 --- /dev/null +++ b/examples/classes/flatapilookup.c @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * flatapilookup.c - + * + * $Id: flatapilookup.c 3097 2014-03-11 11:40:13Z scribe $ + * + * Copyright 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 +#include + +#include + +int main(int argc, char **argv) { + if (argc != 3) { + fprintf(stderr, "\nusage: %s <\"lookup key\">\n" + "\tExample: lookup KJV \"James 1:19\"\n\n", argv[0]); + exit(-1); + } + + + SWHANDLE mgr = org_crosswire_sword_SWMgr_new(); + + SWHANDLE module = org_crosswire_sword_SWMgr_getModuleByName(mgr, argv[1]); + + if (!module) { + fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]); + const struct org_crosswire_sword_ModInfo *modInfos = org_crosswire_sword_SWMgr_getModInfoList(mgr); + while (modInfos && modInfos->name) { + fprintf(stderr, "[%s]\t - %s\n", modInfos->name, modInfos->description); + ++modInfos; + } + org_crosswire_sword_SWMgr_delete(mgr); + exit(-1); + } + + org_crosswire_sword_SWModule_setKeyText(module, argv[2]); + + // we render before we print keyText so our keyText snaps to the closest entry + const char *renderText = org_crosswire_sword_SWModule_renderText(module); + printf("==Render=Entry============\n"); + printf("%s\n", org_crosswire_sword_SWModule_getKeyText(module)); + printf("%s\n", renderText); + printf("==========================\n"); + + org_crosswire_sword_SWMgr_delete(mgr); + + return 0; +} diff --git a/examples/classes/flatapiparsekey.c b/examples/classes/flatapiparsekey.c new file mode 100644 index 0000000..41f7118 --- /dev/null +++ b/examples/classes/flatapiparsekey.c @@ -0,0 +1,65 @@ +/****************************************************************************** + * + * flatapiparsekey.c - + * + * $Id: flatapiparsekey.c 3097 2014-03-11 11:40:13Z scribe $ + * + * Copyright 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 +#include + +#include + +int main(int argc, char **argv) { + if (argc != 3) { + fprintf(stderr, "\nusage: %s <\"keyText\">\n" + "\tExample: %s KJV \"James 1:19-30,34\"\n\n", argv[0], argv[0]); + exit(-1); + } + + + SWHANDLE mgr = org_crosswire_sword_SWMgr_new(); + + SWHANDLE module = org_crosswire_sword_SWMgr_getModuleByName(mgr, argv[1]); + + if (!module) { + fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]); + const struct org_crosswire_sword_ModInfo *modInfos = org_crosswire_sword_SWMgr_getModInfoList(mgr); + while (modInfos && modInfos->name) { + fprintf(stderr, "[%s]\t - %s\n", modInfos->name, modInfos->description); + ++modInfos; + } + org_crosswire_sword_SWMgr_delete(mgr); + exit(-1); + } + + const char **results = org_crosswire_sword_SWModule_parseKeyList(module, argv[2]); + + printf("==========================\n"); + printf("Parsing: %s\n", argv[2]); + printf("==========================\n"); + while (results && *results) { + printf("%s\n", *results); + ++results; + } + printf("==========================\n"); + + org_crosswire_sword_SWMgr_delete(mgr); + + return 0; +} diff --git a/examples/classes/flatapisearch.c b/examples/classes/flatapisearch.c new file mode 100644 index 0000000..715d6bc --- /dev/null +++ b/examples/classes/flatapisearch.c @@ -0,0 +1,66 @@ +/****************************************************************************** + * + * flatapisearch.c - + * + * $Id: flatapisearch.c 3102 2014-03-12 04:55:44Z chrislit $ + * + * Copyright 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 +#include + +#include + +int main(int argc, char **argv) { + if (argc != 3) { + fprintf(stderr, "\nusage: %s <\"search terms\">\n" + "\tExample: %s KJV \"God love world\"\n\n", argv[0], argv[0]); + exit(-1); + } + + + SWHANDLE mgr = org_crosswire_sword_SWMgr_new(); + + SWHANDLE module = org_crosswire_sword_SWMgr_getModuleByName(mgr, argv[1]); + + if (!module) { + fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]); + const struct org_crosswire_sword_ModInfo *modInfos = org_crosswire_sword_SWMgr_getModInfoList(mgr); + while (modInfos && modInfos->name) { + fprintf(stderr, "[%s]\t - %s\n", modInfos->name, modInfos->description); + ++modInfos; + } + org_crosswire_sword_SWMgr_delete(mgr); + exit(-1); + } + + + const struct org_crosswire_sword_SearchHit *results = org_crosswire_sword_SWModule_search(module, argv[2], org_crosswire_sword_SWModule_SEARCHTYPE_MULTIWORD, 0, 0, 0); + + printf("==========================\n"); + printf("Parsing: %s\n", argv[2]); + printf("==========================\n"); + while (results && results->modName) { + printf("%s\n", results->key); + ++results; + } + printf("==========================\n"); + + org_crosswire_sword_SWMgr_delete(mgr); + + return 0; +} diff --git a/examples/classes/lastVerseInChapter.cpp b/examples/classes/lastVerseInChapter.cpp new file mode 100644 index 0000000..aac905c --- /dev/null +++ b/examples/classes/lastVerseInChapter.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * lastVerseInChapter.cpp - This example demonstrates how to navigate + * verses using VerseKey. It uselessly iterates + * every chapter of the KJV, finds the last verse + * and prints out the sole verse in the KJV which + * ends in a ',' -- just for fun. + * + * $Id: lastVerseInChapter.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * 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 +#include +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + SWMgr library; + + SWModule *book = library.getModule("KJV"); + + VerseKey *vk = (VerseKey *) book->getKey(); + for (;!vk->popError();vk->setChapter(vk->getChapter()+1)) { + vk->setVerse(vk->getVerseMax()); + SWBuf text = book->stripText(); + text = text.trim(); + if (text.endsWith(",")) { + cout << vk->getText() << ":\n\n"; + cout << text << endl; + } + } + + return 0; +} + diff --git a/examples/classes/simplechapter.cpp b/examples/classes/simplechapter.cpp new file mode 100644 index 0000000..489f730 --- /dev/null +++ b/examples/classes/simplechapter.cpp @@ -0,0 +1,57 @@ +/****************************************************************************** + * + * simplechapter.cpp - + * + * $Id: simplechapter.cpp 3045 2014-03-02 07:53:52Z chrislit $ + * + * 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 +#include +#include +#include + + +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; +} + diff --git a/examples/classes/swmgrex.cpp b/examples/classes/swmgrex.cpp new file mode 100644 index 0000000..7fc9f73 --- /dev/null +++ b/examples/classes/swmgrex.cpp @@ -0,0 +1,78 @@ +/****************************************************************************** + * + * swmgrex.cpp - 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: swmgrex.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 1998-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 + +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + SWMgr manager; // create a default manager that looks in the current directory for mods.conf + + cout << "\nInstalled Modules:\n\n"; + + ModMap::iterator modIterator; + +// Loop thru all installed modules and print out information + + for (modIterator = manager.Modules.begin(); modIterator != manager.Modules.end(); modIterator++) { + SWBuf modName = (*modIterator).first; // mod.conf section name (stored in module->Name()) + SWModule *module = (*modIterator).second; + + cout << modName << "(" << module->getName() << ") | " << module->getType() << "\n"; + } + +// Print out a verse from the first module: + + cout << "\n" << manager.Modules.begin()->second->getKeyText() << ":\n"; + cout << manager.Modules.begin()->second->renderText(); + cout << " (" << manager.Modules.begin()->second->getName() << ")\n"; + +// Print out the same verse from the second module (less confusing): + + modIterator = manager.Modules.begin(); // get first module + modIterator++; // increment to next module + + SWModule *mod = modIterator->second; + + cout << "\n" << mod->getKeyText() << ":\n"; +// cout << (const char *)(*mod); // we could do this, the same as above + mod->display(); // instead of casting mod to const char * to get its contents, we'll call the default display method that writes to stdout; + cout << " (" << mod->getName() << ")\n\n"; + + return 0; + +} diff --git a/examples/classes/versenorm.cpp b/examples/classes/versenorm.cpp new file mode 100644 index 0000000..08bad54 --- /dev/null +++ b/examples/classes/versenorm.cpp @@ -0,0 +1,72 @@ +/****************************************************************************** + * + * versenorm.cpp - checks normalization of verse to module + * + * $Id$ + * + * Copyright 2012-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 +#include +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + const char *modName = "RusCARS"; + const char *keyTextRegular = "1Sam1.20"; + const char *keyTextNeedsNormalization = "1Sam1.200"; + + + SWMgr library; + SWModule *book = library.getModule(modName); + if (!book) { + cerr << "Can't find module: " << modName << endl; + return -1; + } + + + // get two VerseKey objects for a module + VerseKey *verse = ((VerseKey *)book->createKey()); + VerseKey *verseNormalized = ((VerseKey *)book->createKey()); + + // turn off autonormalization for one VerseKey reference + verse->setAutoNormalize(false); + + // set a reference not requiring normalization to both VerseKey objects + verse->setText(keyTextRegular); + verseNormalized->setText(keyTextRegular); + + // check to see if they are equal + cout << *verse << ((*verse) == (*verseNormalized) ? " == " : " != ") << *verseNormalized << endl; + + // now do the same for a reference which requires normalization in this module's v11n system + verse->setText(keyTextNeedsNormalization); + verseNormalized->setText(keyTextNeedsNormalization); + + cout << *verse << ((*verse) == (*verseNormalized) ? " == " : " != ") << *verseNormalized << endl; + + delete verse; + delete verseNormalized; + + return 0; +} diff --git a/examples/classes/verseposition.cpp b/examples/classes/verseposition.cpp new file mode 100644 index 0000000..8e63cb5 --- /dev/null +++ b/examples/classes/verseposition.cpp @@ -0,0 +1,51 @@ +/****************************************************************************** + * + * verseposition.cpp - + * + * $Id: verseposition.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 2012-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 +#include +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + const char *modName = "HunKar"; + SWMgr library; + SWModule *book = library.getModule(modName); + if (!book) { + cerr << "Can't find module: " << modName << endl; + return -1; + } + VerseKey* key = ((VerseKey *)book->getKey()); + + key->setIntros(true); + book->setSkipConsecutiveLinks(true); + book->setPosition(TOP); + + cout << *key << endl; + + return 0; +} diff --git a/examples/classes/verseranges.cpp b/examples/classes/verseranges.cpp new file mode 100644 index 0000000..557855a --- /dev/null +++ b/examples/classes/verseranges.cpp @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * verseranges.cpp - This example demonstrates how to work with contiguous + * verse ranges using VerseKey + * + * $Id: verseranges.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * 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 + +#include +#include +#include + + +using namespace sword; +using namespace std; + + +int main(int argc, char **argv) { + + cout << "\n"; + + const char *modName = "KJVA"; + SWMgr manager; + SWModule *bible = manager.getModule(modName); + if (!bible) { + cout << modName << " not installed for example. Please install.\n\n"; + exit(-1); + } + + VerseKey *vk = (VerseKey *)bible->createKey(); + + // let's set verse ranges for a variety of different contiguous regions + + // set a verse range for the whole Bible + vk->setLowerBound(*vk); // vk initially points to TOP, so we don't need to set position first + vk->setPosition(BOTTOM); + vk->setUpperBound(*vk); + cout << vk->getRangeText() << "\n"; + + + vk->clearBounds(); + + + // Old Testament + vk->setPosition(TOP); + vk->setLowerBound(*vk); + + vk->setTestament(2); + (*vk)--; + + vk->setUpperBound(*vk); + cout << vk->getRangeText() << "\n"; + + + vk->clearBounds(); + + + // New Testament + vk->setPosition(TOP); + vk->setTestament(2); + vk->setLowerBound(*vk); + vk->setPosition(BOTTOM); + vk->setUpperBound(*vk); + cout << vk->getRangeText() << "\n"; + + + vk->clearBounds(); + + + // Current Book + vk->setText("John 3:16"); + vk->setChapter(1); vk->setVerse(1); + vk->setLowerBound(*vk); + vk->setChapter(vk->getChapterMax()); vk->setVerse(vk->getVerseMax()); + vk->setUpperBound(*vk); + cout << vk->getRangeText() << "\n"; + + + // ------------------------- + // Shorter syntax using the parser and based on book names, and requires intimate knowledge of VersificationMgr + // You're probably better off using the above code, but this is here for completeness + // + const VersificationMgr::System *refSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem(vk->getVersificationSystem()); + + + // whole Bible + VerseKey vkBible(refSys->getBook(0)->getOSISName(), refSys->getBook(refSys->getBookCount()-1)->getOSISName(), refSys->getName()); + cout << vkBible.getRangeText() << "\n"; + + // OT + VerseKey vkOT(refSys->getBook(0)->getOSISName(), refSys->getBook(refSys->getBMAX()[0]-1)->getOSISName(), refSys->getName()); + cout << vkOT.getRangeText() << "\n"; + + // NT + VerseKey vkNT(refSys->getBook(refSys->getBMAX()[0])->getOSISName(), refSys->getBook(refSys->getBookCount()-1)->getOSISName(), refSys->getName()); + cout << vkNT.getRangeText() << "\n"; + + // Current Book + vk->setText("John 3:16"); + VerseKey vkCurrentBook(vk->getBookName(), vk->getBookName(), refSys->getName()); + cout << vkCurrentBook.getRangeText() << "\n"; + + + delete vk; + + cout << endl; + + return 0; +} + -- cgit v1.2.3