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.getText().c_str(), true); // let's iterate the key and display for (result.positionToTop(); !result.popError(); result.increment()) { cout << result.getText() << "\n"; } cout << endl; // Now let's output a module with the entries from the result // we'll initialize our library of books SWMgr library(std::make_shared<MarkupFilterMgr>(FMT_PLAIN)); // render plain without fancy markup // Let's get a book; auto const book(library.getModule("KJV")); // couldn't find our test module if (!book) return -1; // now let's iterate the book and display for (result.positionToTop(); !result.popError(); result.increment()) { book->setKey(result); cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n"; } return 0; }
void writeEntry(SWModule & module, std::string const & key, std::string const & entry, bool const replace) { if (key.size() && entry.size()) { std::cout << "from file: " << key << std::endl; VerseKey *vkey = (VerseKey *)module.getKey(); std::unique_ptr<VerseKey> linkMaster( static_cast<VerseKey *>(module.createKey().release())); ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true); bool first = true; for (listKey.positionToTop(); !listKey.popError(); listKey.increment()) { vkey->positionFrom(listKey); if (first) { *linkMaster = *vkey; std::string text; if (!replace) text = module.getRawEntry(); text += entry; std::cout << "adding entry: " << vkey->getText() << " length " << entry.size() << "/" << (unsigned short)text.size() << std::endl; module.setEntry(text.c_str()); first = false; } else { std::cout << "linking entry: " << vkey->getText() << " to " << linkMaster->getText() << std::endl; module.linkEntry(*linkMaster); } } } }