diff options
Diffstat (limited to 'examples/cmdline/verserangeparse.cpp')
-rw-r--r-- | examples/cmdline/verserangeparse.cpp | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/examples/cmdline/verserangeparse.cpp b/examples/cmdline/verserangeparse.cpp index aa8cf71..d5fd18b 100644 --- a/examples/cmdline/verserangeparse.cpp +++ b/examples/cmdline/verserangeparse.cpp @@ -1,11 +1,11 @@ -/****************************************************************** - * This example shows: - * How to parse a verse reference - * How to persist a custom range key in a book +/****************************************************************************** * - * $Id: swmgr.h 2321 2009-04-13 01:17:00Z scribe $ + * verserangeparse.cpp - This example shows + * how to parse a verse reference * - * Copyright 1998-2009 CrossWire Bible Society (http://www.crosswire.org) + * $Id: verserangeparse.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -45,42 +45,30 @@ int main(int argc, char **argv) VerseKey parser; ListKey result; - result = parser.ParseVerseList(range, parser, true); + result = parser.parseVerseList(range, parser, true); + // let's iterate the key and display - for (result = TOP; !result.Error(); result++) { + 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.Persist(true); + // Now let's output a module with the entries from the result - // Let's get a book; + // we'll initialize our library of books SWMgr library(new MarkupFilterMgr(FMT_PLAIN)); // render plain without fancy markup + + // Let's get a book; SWModule *book = library.getModule("KJV"); - // and set our limited key inside - book->setKey(result); + // couldn't find our test module + if (!book) return -1; // now let's iterate the book and display - for ((*book) = TOP; !book->Error(); (*book)++) { - cout << "*** " << book->getKeyText() << ": " << book->RenderText() << "\n"; + for (result = TOP; !result.popError(); result++) { + book->setKey(result); + 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"); - // - // this allows book to create and use an instance of its preferred key type - // - return 0; } |