int main(int argc, char **argv) { SWMgr mgr; SWModule *mod = mgr.getModule("KJVgb"); VerseKey *key1 = (VerseKey *)mod->createKey(); key1->setTestament(2); key1->setBook(4); key1->setChapter(2); key1->setVerse(3); cout << "\n" << key1->getText() << ":\n\n"; ListKey keys; keys << *key1; cout << "\n" << keys.getRangeText() << ":\n\n"; ListKey keys2 = keys; cout << "\n" << keys2.getRangeText() << ":\n\n"; keys = key1->parseVerseList("Lk.4.5"); cout << "\n" << key1->getText() << ":\n\n"; key1->setText("jn.6.7"); cout << "\n" << key1->getText() << ":\n\n"; mod->setKey("lk.2.3"); cout << "\n" << mod->getKeyText() << ":\n" << endl; cout << mod->getRawEntry() << endl; cout << "\nListkey persist key iteration test\n\n"; keys = key1->parseVerseList("mat1", 0, true); for (keys = TOP; !keys.popError(); keys++) { cout << "\n" << keys.getText() << ":\n" << endl; } keys.setPersist(true); mod->setKey(keys); for ((*mod) = TOP; !mod->popError(); (*mod)++) { cout << "\n" << mod->getKeyText() << ":\n" << endl; } delete key1; return 0; }
const char *SWModule_getFootnoteRefList(SWHANDLE hmodule, const char *key, const char *note) { SWModule *module = (SWModule *)hmodule; static SWBuf refList; module->popError(); module->setKey(key); module->renderText(); refList = module->getEntryAttributes()["Footnote"][note]["refList"].c_str(); return (refList) ? (const char*)refList.c_str() : NULL; }
const char *SWModule_getFootnoteType(SWHANDLE hmodule, const char *key, const char *note) { SWModule *module = (SWModule *)hmodule; static SWBuf type; module->popError(); module->setKey(key); module->renderText(); type = module->getEntryAttributes()["Footnote"][note]["type"].c_str(); return (type) ? (const char*)type.c_str() : NULL; }
const char *SWModule_getFootnoteBody(SWHANDLE hmodule, const char *key, const char *note) { SWModule *module = (SWModule *)hmodule; static SWBuf body; module->popError(); module->setKey(key); module->renderText(); body = module->getEntryAttributes()["Footnote"][note]["body"].c_str(); SWKey *keybuf = module->getKey();; module->renderFilter(body, keybuf); return (body) ? (const char*)body.c_str() : NULL; }
int main(int argc, char **argv) { SWMgr mymgr; SWModule *bbe = mymgr.Modules["BBE"]; if (bbe) { VerseKey vk; vk.setPersist(true); bbe->setKey(vk); for (; !bbe->popError(); (*bbe)++ ) { std::cout << vk.getIndex() << std::endl; } } return 0; }
int main(int argc, char **argv) { const char *range = (argc > 1) ? argv[1] : "Mat 2:10,12-15"; VerseKey parser; ListKey result; result = parser.parseVerseList(range, parser, true); // let's iterate the key and display for (result = TOP; !result.popError(); result++) { cout << result << "\n"; } cout << endl; // Now if we'd like persist this key for use inside of a book... result.setPersist(true); // Let's get a book; SWMgr library(new MarkupFilterMgr(FMT_PLAIN)); // render plain without fancy markup SWModule *book = library.getModule("KJV"); // and set our limited key inside book->setKey(result); // now let's iterate the book and display for ((*book) = TOP; !book->popError(); (*book)++) { cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n"; } // Since we've told our result key to persist in book, we can reuse our // setup by simply resetting result, e.g. // // result = parser.ParseVerseList(someNewRange, parser, true); // // Now an iteration of book will give us our new range. // // To stop persistence of our custom key, we'll need to set our book's key // to something simple: // // book->setKey("gen.1.1"); // // Resetting our book object's key to something not persistent will revert our book object to using its default key for positioning // // return 0; }
int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "usage: %s <Mod Name>\n", argv[0]); exit(-1); } SWMgr mgr; ModMap::iterator it = mgr.Modules.find(argv[1]); if (it == mgr.Modules.end()) { fprintf(stderr, "error: %s: couldn't find module: %s \n", argv[0], argv[1]); exit(-2); } SWModule *mod = it->second; SWKey *key = (*mod); VerseKey *vkey = 0; SWTRY { vkey = dynamic_cast<VerseKey *>(key); } SWCATCH (...) {} if (!vkey) { fprintf(stderr, "error: %s: %s module is not keyed to verses \n", argv[0], argv[1]); exit(-3); } vkey->setIntros(false); // turn on mod/testmnt/book/chap headings (*mod) = TOP; while (!mod->popError()) { if (vkey->getVerse()) if (!mod->renderText().length()) std::cout << *vkey << std::endl; (*mod)++; } }
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; }
/** Gets and clears error status * * @return error status */ char SWModule_error(SWHANDLE hmodule) { SWModule *module = (SWModule *)hmodule; return (module) ? module->popError() : 0; }