diff options
Diffstat (limited to 'examples/cmdline/outplain.cpp')
-rw-r--r-- | examples/cmdline/outplain.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/examples/cmdline/outplain.cpp b/examples/cmdline/outplain.cpp index f95be88..5245fda 100644 --- a/examples/cmdline/outplain.cpp +++ b/examples/cmdline/outplain.cpp @@ -1,11 +1,17 @@ /****************************************************************************** - * This example show how to output the plain text entries from a SWORD module. - * This is also good for speed tests + * + * outplain.cpp - This example shows how to output the plain text + * entries from a SWORD module. This small program + * outputs a SWORD module in 'imp' format, e.g.: + * + * $$$Gen.1.1 + * In the beginning God created + * the heavens and the earth + * + * $$$Gen.1.2 + * ... * * Class SWMgr manages installed modules for a frontend. - * SWMgr reads a mods.conf file to discover its information. - * It then instantiates the correct decendent of SWModule for each - * module entry in mods.conf * The developer may use this class to query what modules are installed * and to retrieve an (SWModule *) for any one of these modules * @@ -14,9 +20,9 @@ * ModMap consists of: FIRST : SWBuf moduleName * SECOND: SWModule *module * - * $Id: swmgr.h 2321 2009-04-13 01:17:00Z scribe $ + * $Id: outplain.cpp 2980 2013-09-14 21:51:47Z scribe $ * - * Copyright 1998-2009 CrossWire Bible Society (http://www.crosswire.org) + * Copyright 2008-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -32,21 +38,6 @@ * */ -/****************************************************************************** - * Class SWMgr manages installed modules for a frontend. - * SWMgr reads a mods.conf file to discover its information. - * It then instantiates the correct decendent of SWModule for each - * module entry in mods.conf - * 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 - * - */ - #include <iostream> #include <swmgr.h> @@ -54,24 +45,29 @@ #include <versekey.h> #include <markupfiltmgr.h> + using namespace sword; using namespace std; + int main(int argc, char **argv) { + SWMgr manager(new MarkupFilterMgr(sword::FMT_HTMLHREF, sword::ENC_UTF16)); const char *bookName = (argc > 1) ? argv[1] : "WLC"; SWModule *b = manager.getModule(bookName); if (!b) return -1; SWModule &book = *b; - book.processEntryAttributes(false); + book.setProcessEntryAttributes(false); VerseKey *vk = SWDYNAMIC_CAST(VerseKey, book.getKey()); - for (book = TOP; !book.Error() && !book.getRawEntryBuf().size(); book++); + for (book = TOP; !book.popError() && !book.getRawEntryBuf().size(); book++); if (!book.getRawEntryBuf().size()) return -2; // empty module - for (;!book.Error(); book++) { + for (;!book.popError(); book++) { cout << "$$$"; if (vk) cout << vk->getOSISRef(); else cout << book.getKeyText(); - cout << "\n" << book.StripText() << "\n\n"; + cout << "\n" << book.stripText() << "\n\n"; } + + return 0; } |