https://wiki.crosswire.org/api.php?action=feedcontributions&user=Underlined&feedformat=atomCrossWire Bible Society - User contributions [en]2024-03-28T18:15:10ZUser contributionsMediaWiki 1.27.7https://wiki.crosswire.org/index.php?title=Main_Page&diff=12919Main Page2013-10-03T16:48:26Z<p>Underlined: /* SWORD based front-ends */</p>
<hr />
<div>{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid green;padding-left:1em;padding-right:0.5em;background:#E4FFDF;padding-bottom:0.5em;" width="100%"|<br />
==Welcome to the CrossWire Developers' Wiki==<br />
Be sure to check out our [[Current Projects|current projects]] page to see how you might use your skills here at [http://crosswire.org/ CrossWire].<br />
<br />
Please look at our general [[Volunteers|volunteering]] page, the [http://www.crosswire.org/bugs bugs] database and/or assist end-users in the [http://www.crosswire.org/forums forums].<br />
<br />
Also, we have pages describing the [[Purpose Statement|purpose]] of our work and the [[About Us|CrossWire Bible Society]] itself.<br />
<br />
You can even come and chat with SWORD developers on IRC: [http://webchat.freenode.net/?randomnick=1&channels=sword&prompt=1 #sword] on FreeNode.<br />
<br />
Newcomers should take note of the difference between SWORD as a [https://en.wikipedia.org/wiki/Front_and_back_ends back-end], and the SWORD Project as a front-end application for Windows.<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
<br />
| style="background:#E8F1FF;border-style:solid;border-width:1px;border-color:#00ccFF;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==SWORD Modules==<br />
* List of Known [[Module Repositories]]<br />
* Information about Unicode [[Fonts]]<br />
* [[Module Requests]]<br />
* [[BibTeX entries]]<br />
<br />
==Front-end Applications==<br />
* [[Choosing a SWORD program]]<br />
* A Front-end [[Frontends:FeatureList|Features Wishlist]]<br />
* [[Frontends:No longer being actively developed|Front-ends no longer being actively developed]]<br />
===SWORD based front-ends===<br />
* [http://www.crosswire.org/sword/software/biblecs/ The SWORD Project for Windows] &ndash; last updated in 2008.<br />
* [[Frontends:Eloquent|Eloquent]] (formerly named MacSword)<br />
* [[Frontends:Xiphos|Xiphos (GTK)]] (formerly [[Frontends:GnomeSword|GnomeSword]])<br />
* [[Frontends:BibleTime|BibleTime]] (see also [[Frontends:KioSword|Kio-Sword]])<br />
* [http://sourceforge.net/projects/bibletimemini/ BibleTime Mini] (for mobiles)<br />
* [http://bpbible.com BPBible (wxPython)]<br />
* [http://swordwarrior.net SwordBible]<br />
* [http://www.crosswire.org/swordweb/ The Bible Tool] &ndash; server application using [http://en.wikipedia.org/wiki/ORBit ORBit]<br />
* [[Frontends:PocketSword|PocketSword]] (for [http://en.wikipedia.org/wiki/IOS_%28Apple%29 Apple iOS])<br />
* [http://sourceforge.net/projects/dbst/ Dexios Bible Study Tool]<br />
* [http://katana.garage.maemo.org/ Katana] (for [http://maemo.org/ maemo] Internet tablets)<br />
* [[Frontends:Diatheke|Diatheke]] (CLI)<br />
* [http://code.google.com/p/xulsword/ xulsword] & [http://code.google.com/p/xulsword/source/browse/#svn%2Ftrunk%2FCpp%2Fphpsword phpsword]<br />
<br />
===JSword based front-ends===<br />
* [[Frontends:BibleDesktop|BibleDesktop]]<br />
* [http://thegoan.com/firebible FireBible] &ndash; Firefox Add-on (with [https://mozillalabs.com/ubiquity/ Ubiquity] support)<br />
* [http://www.kiyut.com/products/alkitab/ Alkitab Bible Study]<br />
* [[Frontends:GSword|GSword]] &ndash; CCIM Online Bible Studio<br />
* [http://code.google.com/p/and-bible/ And Bible] &ndash; for Android OS<br />
* [http://www.stepbible.org/ STEP Bible] &ndash; developed at [http://www.tyndale.cam.ac.uk/ Tyndale House]<br />
<br />
==Other CrossWire Applications==<br />
* [[Projects:Go Bible|Go Bible]] &ndash; mobile phone Bible viewer for Java ME<br />
<br />
|valign="top" bgcolor="#FFE8E8" style="border-style:solid;border-width:1px;border-color:#FF6060;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==Development Tools==<br />
* [[DevTools:SWORD|SWORD Engine (C++)]]<br />
* [[DevTools:JSword|JSword (Java)]]<br />
* [[:DevTools:Code Examples|Code Examples]]<br />
* [[Tutorial:How SWORD works]]<br />
* [[:Tutorial:Compiling & Installing SWORD]]<br />
* [[DevTools:ICU|International Components for Unicode (ICU)]]<br />
* [[DevTools:CMake|CMake]] & [[DevTools:Bindings|Bindings]] for SWORD &ndash; experimental<br />
<br />
==Module Development==<br />
* How to Create [[DevTools:Modules|SWORD Modules]]<br />
* How to Create [[DevTools:conf Files|Module .conf Files]]<br />
* A Basic [[OSIS Tutorial]]<br />
* Guide to Writing [[OSIS Bibles]]<br />
* Guide to Writing [[OSIS Commentaries]]<br />
* Guide to Writing [[OSIS Genbooks]]<br />
* Guide to Writing [[ThML modules]]<br />
* Guide to Writing [[TEI Dictionaries]]<br />
* Guide to [[Converting SFM Bibles to OSIS]]<br />
* About [[DevTools:JSword/Personal Commentary|Personal Commentaries]]<br />
* About [[Alternate Versification]]<br />
* [[OpenOffice Export Filter for Genbooks]]<br />
* [[File Formats]] and related Utility Programs<br />
* [[DevTools:Text Editors|Unicode Text Editors]]<br />
* [[Modules_in_the_beta_repository|Testing status of Beta modules]]<br />
* Guide to [[Creating and Maintaining a Module Repository]]<br />
* [[Non-CrossWire Text-Development Projects]]<br />
<br />
==Public Relations, Website, User assistance==<br />
* [[EnduserFAQ|FAQ]]<br />
* [[Project websites and domains]]<br />
* [[Help:Contents|Getting help]], joining mailing lists and reporting problems<br />
* [[Copyright]] policy and lobbying copyright owners<br />
* [[Twitter|CrossWire on Twitter]] and [[Facebook]]<br />
* [[SWORD CD]]<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid gray;padding-left:1em;padding-right:0.5em;background:#E8E8E8;padding-bottom:0.5em;" width="100%"|<br />
<br />
==Getting Started in Wiki Collaboration==<br />
A Wiki is a place to share documentation and development information.<br />
* New user account requests are now moderated.<br />
* Anyone who has been a member for at least 4 days can edit a wiki once they have [[Special:Userlogin|logged in]].<br />
* If you are new to Wikis, consult the [http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide User's Guide] for information on using the wiki software.<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* You may experiment with Wiki using our [[CrossWire:Sandbox|Sandbox]].<br />
* Another way to navigate the Wiki is to click on [[:Special:SpecialPages|Special pages]] in the toolbox, and then select [[:Special:Categories|Categories]], or just go directly to [[:Category:Categories]].<br />
|}<br />
<br />
[[Category:CrossWire]]<br />
[[Category:SWORD Frontends]]<br />
[[Category:JSword]]<br />
[[Category:Modules]]<br />
[[Category:Development tools]]<br />
[[Category:Support]]<br />
__NOTOC__</div>Underlinedhttps://wiki.crosswire.org/index.php?title=Main_Page&diff=7800Main Page2010-03-02T11:29:12Z<p>Underlined: /* SWORD Front-ends */</p>
<hr />
<div>{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid green;padding-left:1em;padding-right:0.5em;background:#E4FFDF;padding-bottom:0.5em;" width="100%"|<br />
==Welcome to the CrossWire Developers' Wiki==<br />
Be sure to check out our [[Current Projects|current projects]] page to see how you might use your skills here at [http://crosswire.org/ CrossWire].<br />
<br />
Please look at our general [[Volunteers|volunteering]] page, the [http://www.crosswire.org/bugs bugs] database and/or assist end-users in the [http://www.crosswire.org/forums forums].<br />
<br />
Also, we have pages describing the [[Purpose Statement|purpose]] of our work and the [[About Us|CrossWire Bible Society]] itself.<br />
<br />
You can even come and chat with SWORD developers on IRC: [http://webchat.freenode.net/?randomnick=1&channels=sword&prompt=1 #sword] on FreeNode.<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
<br />
| style="background:#E8F1FF;border-style:solid;border-width:1px;border-color:#00ccFF;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==SWORD Modules==<br />
* List of Known [[Module Repositories]]<br />
* Information about Unicode [[Fonts]]<br />
* [[Module Requests]]<br />
<br />
==Front-end Applications==<br />
* [[Choosing a SWORD program]]<br />
* A Front-end [[Frontends:FeatureList|Features Wishlist]]<br />
===SWORD Front-ends===<br />
* [[Frontends:BibleCS|The SWORD Project for Windows]]<br />
* [[Frontends:MacSword|MacSword]]<br />
* [[Frontends:Xiphos|Xiphos (GNOME)]] (formerly [[Frontends:GnomeSword|GnomeSword]])<br />
* [http://devel.bibletime.info BibleTime] (see also [[Frontends:KioSword|Kio-Sword]])<br />
* [http://bpbible.com BPBible (wxPython)]<br />
* [http://swordwarrior.net SwordBible]<br />
* [http://www.crosswire.org/swordweb/ The Bible Tool] &ndash; server application using [http://en.wikipedia.org/wiki/ORBit ORBit]<br />
* [http://hurdygurdy.dyndns.org/maemosword/ Rapier] (for [http://maemo.org/ maemo] Internet tablets)<br />
* [http://crosswire.org/pocketsword/ PocketSword] (for the iPhone & iPod Touch)<br />
* [http://code.google.com/p/dbst/ Dexios Bible Study Tool]<br />
<br />
===JSword Front-ends===<br />
* [[Frontends:BibleDesktop|BibleDesktop]]<br />
* [http://thegoan.com/firebible FireBible] &ndash; Firefox Add-on (with [https://mozillalabs.com/ubiquity/ Ubiquity] support)<br />
* [http://www.kiyut.com/products/alkitab/ Alkitab Bible Study]<br />
* [http://kokkos.org/ Kokkos] &ndash; Chinese<br />
* [http://rock.ccim.org/gsword/gbook/v GSword] &ndash; CCIM Online Bible Studio<br />
<br />
===No longer actively being developed===<br />
* [[Frontends:BibleStudy|BibleStudy]] (wxWidgets)<br />
* [[Frontends:Diatheke|Diatheke]] (CLI)<br />
* [[Frontends:SWORDReader|SWORDReader]] (PocketPC handhelds)<br />
<br />
|valign="top" bgcolor="#FFE8E8" style="border-style:solid;border-width:1px;border-color:#FF6060;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==Development Tools==<br />
* [[DevTools:SWORD|SWORD Engine (C++)]]<br />
* [[DevTools:JSword|JSword (Java)]]<br />
* [[:DevTools:Code Examples|Code Examples]]<br />
* [[:Tutorial:Compiling & Installing SWORD]]<br />
* [[DevTools:ICU|International Components for Unicode (ICU)]]<br />
<br />
==Module Development==<br />
* How to Create [[DevTools:Modules|SWORD Modules]]<br />
* How to Create [[DevTools:confFiles|Module .conf Files]]<br />
* A Basic [[OSIS Tutorial]]<br />
* Guide to Writing [[OSIS Bibles]]<br />
* Guide to Writing [[OSIS Commentaries]]<br />
* Guide to Writing [[OSIS Genbooks]]<br />
* Guide to Writing [[ThML modules]]<br />
* Guide to Writing [[TEI Dictionaries]]<br />
* Guide to [[Converting SFM Bibles to OSIS]]<br />
* About [[DevTools:JSword/Personal Commentary|Personal Commentaries]]<br />
* [[OpenOffice Export Filter for Genbooks]]<br />
* [[File Formats]] and related Utility Programs<br />
* [[Modules_in_the_beta_repository|Testing status of Beta modules]]<br />
* Guide to [[Creating and Maintaining a Module Repository]]<br />
* [[Non-CrossWire Text-Development Projects]]<br />
<br />
==Public Relations, Website, User assistance==<br />
* [[EnduserFAQ|FAQ]]<br />
* [[Project websites and domains]]<br />
* [[Help:Contents|Getting help]] and reporting problems<br />
* [[Copyright|Copyright lobbying]]<br />
* [[Twitter|CrossWire on Twitter]] and [[Facebook]]<br />
* [[SWORD CD]]<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid gray;padding-left:1em;padding-right:0.5em;background:#E8E8E8;padding-bottom:0.5em;" width="100%"|<br />
<br />
==Getting Started in Wiki Collaboration==<br />
A Wiki is a place to share documentation and development information.<br />
* Anyone who has been a member for at least 4 days can edit a wiki once they have [[Special:Userlogin|logged in]].<br />
* If you are new to Wikis, consult the [http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide User's Guide] for information on using the wiki software.<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* You may experiment with Wiki using our [[CrossWire:Sandbox|Sandbox]].<br />
|}<br />
<br />
[[Category:CrossWire]]<br />
[[Category:SWORD Frontends]]<br />
[[Category:JSword]]<br />
[[Category:Modules]]<br />
[[Category:Development tools]]<br />
[[Category:Support]]<br />
__NOTOC__</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7749DevTools:Code Examples2010-01-20T03:12:24Z<p>Underlined: /* Install Manager */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules may potentially employ any of the basic module types (Genbook, LD, Com, or Text). The most consistent way to differentiate between a map or image module and the basic module types is to look for the configuration entry "Feature":<br />
<pre><br />
if (QString(module->getConfigEntry("Feature")) == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
----<br />
<br />
==== Getting Generic Book Table of Contents ====<br />
<br />
[http://www.crosswire.org/~ghellings/svnclassdocs/classTreeKey.html TreeKey] is necessary for traversing the generic book's tree. I am going to let the comments and function names speak for themselves here. Assume that <tt>module</tt> points to a [http://www.crosswire.org/~ghellings/svnclassdocs/classSWModule.html SWModule] object.<br />
<pre><br />
#include <swmodule.h><br />
#include <treekey.h><br />
<br />
void getGenBookTOC(sword::TreeKey *tk, Class *parent)<br />
{<br />
// if no TreeKey, then obtain one from the module<br />
if (!tk)<br />
tk = dynamic_cast<sword::TreeKey*>(module->getKey());<br />
<br />
// Move onto the first child if any<br />
if (tk->firstChild())<br />
{<br />
// Get the first child's information before moving onto the next<br />
do<br />
{<br />
// Retrieve the name so we can use it to get<br />
// the GenBook's content later<br />
QString text = tk->getText();<br />
// Keep track of the information for custom implementation<br />
Class *item = storeItemInfoForLaterUse(parent, text);<br />
<br />
// If it has children, dive into it<br />
if (tk->hasChildren())<br />
getGenBookTOC(tk, item);<br />
}<br />
// Move onto the next child if any<br />
while (tk->nextSibling());<br />
// Move up one level in case one of the children had children<br />
tk->parent();<br />
}<br />
}<br />
</pre><br />
How you go about in implementing this is up to you.<br />
<br />
[[Category:Genbook]]<br />
<br />
==== Install Manager ====<br />
<br />
The [http://www.crosswire.org/~ghellings/svnclassdocs/classInstallMgr.html InstallMgr] class is pretty easy to work with and will manage most of the install sources itself. When instantiated, it will generate the list of sources (which can later be accessed from its public attribute, <tt>sources</tt>) from the InstallMgr.conf located at the path provided in the constructor's first paramater, <tt>privatePath</tt>, if any. If no InstallMgr.conf exists, you can use the method <tt>refreshRemoteSourceConfiguration()</tt> to retrieve a list of sources remotely. <tt>refreshRemoteSourceConfiguration()</tt> will return 0 upon success. If -1 is returned, you should check to see if <tt>isUserDisclaimerConfirmed()</tt> returns false; <tt>isUserDisclaimerConfirmed()</tt> must return true to get passed the first process when refreshing the remote source.<br />
<br />
When working with the InstallMgr class, it will be useful to have a SWMgr object lying around <i>before</i> installing any new modules and refreshing any remote sources. This is so you can provide some additional module information to the user with the help of <tt>InstallMgr::getModuleStatus()</tt>. You rely on the return value of <tt>InstallMgr::getModuleStatus()</tt> to display the list of modules and whether they are new (not installed) (<tt>InstallMgr::MODSTAT_NEW</tt>), already installed (<tt>InstallMgr::MODSTAT_SAMEVERSION</tt>), an update is available (<tt>InstallMgr::MODSTAT_UPDATED</tt>), et cetera.<br />
<br />
To install modules you would of course use the method <tt>installModule()</tt>. Local installs make use of only the first three parameters; remote installs make use of the first and last two while passing 0 to the second parameter. Note, the name of the module you want to install is obtained through <tt>SWModule::Name()</tt>. <tt>installModule()</tt> will return 0 on success.<br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7746DevTools:Code Examples2010-01-19T02:45:57Z<p>Underlined: /* C++ */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules may potentially employ any of the basic module types (Genbook, LD, Com, or Text). The most consistent way to differentiate between a map or image module and the basic module types is to look for the configuration entry "Feature":<br />
<pre><br />
if (QString(module->getConfigEntry("Feature")) == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
----<br />
<br />
==== Getting Generic Book Table of Contents ====<br />
<br />
[http://www.crosswire.org/~ghellings/svnclassdocs/classTreeKey.html TreeKey] is necessary for traversing the generic book's tree. I am going to let the comments and function names speak for themselves here. Assume that <tt>module</tt> points to a [http://www.crosswire.org/~ghellings/svnclassdocs/classSWModule.html SWModule] object.<br />
<pre><br />
#include <swmodule.h><br />
#include <treekey.h><br />
<br />
void getGenBookTOC(sword::TreeKey *tk, Class *parent)<br />
{<br />
// if no TreeKey, then obtain one from the module<br />
if (!tk)<br />
tk = dynamic_cast<sword::TreeKey*>(module->getKey());<br />
<br />
// Move onto the first child if any<br />
if (tk->firstChild())<br />
{<br />
// Get the first child's information before moving onto the next<br />
do<br />
{<br />
// Retrieve the name so we can use it to get<br />
// the GenBook's content later<br />
QString text = tk->getText();<br />
// Keep track of the information for custom implementation<br />
Class *item = storeItemInfoForLaterUse(parent, text);<br />
<br />
// If it has children, dive into it<br />
if (tk->hasChildren())<br />
getGenBookTOC(tk, item);<br />
}<br />
// Move onto the next child if any<br />
while (tk->nextSibling());<br />
// Move up one level in case one of the children had children<br />
tk->parent();<br />
}<br />
}<br />
</pre><br />
How you go about in implementing this is up to you.<br />
<br />
[[Category:Genbook]]<br />
<br />
==== Install Manager ====<br />
<br />
The [http://www.crosswire.org/~ghellings/svnclassdocs/classInstallMgr.html InstallMgr] class is pretty easy to work with and will manage most of the install sources itself. When instantiated, it will generate the list of sources (which can later be accessed from its public attribute, <tt>sources</tt>) from the InstallMgr.conf located at the path provided in the constructor's first paramater, <tt>privatePath</tt>, if any. If no InstallMgr.conf exists, you can use the method <tt>refreshRemoteSourceConfiguration()</tt> to retrieve a list of sources remotely. <tt>refreshRemoteSourceConfiguration()</tt> will return 0 upon success.<br />
<br />
When working with the InstallMgr class, it will be useful to have a SWMgr object lying around <i>before</i> installing any new modules and refreshing any remote sources. This is so you can provide some additional module information to the user with the help of <tt>InstallMgr::getModuleStatus()</tt>. You rely on the return value of <tt>InstallMgr::getModuleStatus()</tt> to display the list of modules and whether they are new (not installed) (<tt>InstallMgr::MODSTAT_NEW</tt>), already installed (<tt>InstallMgr::MODSTAT_SAMEVERSION</tt>), an update is available (<tt>InstallMgr::MODSTAT_UPDATED</tt>), et cetera.<br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7378DevTools:Code Examples2009-12-05T17:11:30Z<p>Underlined: /* Getting Generic Book Table of Contents */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules may potentially employ any of the basic module types (Genbook, LD, Com, or Text). The most consistent way to differentiate between a map or image module and the basic module types is to look for the configuration entry "Feature":<br />
<pre><br />
if (QString(module->getConfigEntry("Feature")) == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
----<br />
<br />
==== Getting Generic Book Table of Contents ====<br />
<br />
[http://www.crosswire.org/~ghellings/svnclassdocs/classTreeKey.html TreeKey] is necessary for traversing the generic book's tree. I am going to let the comments and function names speak for themselves here. Assume that <tt>module</tt> points to a [http://www.crosswire.org/~ghellings/svnclassdocs/classSWModule.html SWModule] object.<br />
<pre><br />
#include <swmodule.h><br />
#include <treekey.h><br />
<br />
void getGenBookTOC(sword::TreeKey *tk, Class *parent)<br />
{<br />
// if no TreeKey, then obtain one from the module<br />
if (!tk)<br />
tk = dynamic_cast<sword::TreeKey*>(module->getKey());<br />
<br />
// Move onto the first child if any<br />
if (tk->firstChild())<br />
{<br />
// Get the first child's information before moving onto the next<br />
do<br />
{<br />
// Retrieve the name so we can use it to get<br />
// the GenBook's content later<br />
QString text = tk->getText();<br />
// Keep track of the information for custom implementation<br />
Class *item = storeItemInfoForLaterUse(parent, text);<br />
<br />
// If it has children, dive into it<br />
if (tk->hasChildren())<br />
getGenBookTOC(tk, item);<br />
}<br />
// Move onto the next child if any<br />
while (tk->nextSibling());<br />
// Move up one level in case one of the children had children<br />
tk->parent();<br />
}<br />
}<br />
</pre><br />
How you go about in implementing this is up to you.<br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7377DevTools:Code Examples2009-12-05T17:08:27Z<p>Underlined: /* C++ */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules may potentially employ any of the basic module types (Genbook, LD, Com, or Text). The most consistent way to differentiate between a map or image module and the basic module types is to look for the configuration entry "Feature":<br />
<pre><br />
if (QString(module->getConfigEntry("Feature")) == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
----<br />
<br />
==== Getting Generic Book Table of Contents ====<br />
<br />
[http://www.crosswire.org/~ghellings/svnclassdocs/classTreeKey.html TreeKey] is necessary for traversing the generic book's tree. I am going to let the comments and function names speak for themselves here. Assume that <tt>module</tt> points to a [http://www.crosswire.org/~ghellings/svnclassdocs/classSWModule.html SWModule] object.<br />
<pre><br />
void getGenBookTOC(sword::TreeKey *tk, Class *parent)<br />
{<br />
// if no TreeKey, then obtain one from the module<br />
if (!tk)<br />
tk = dynamic_cast<sword::TreeKey*>(module->getKey());<br />
<br />
// Move onto the first child if any<br />
if (tk->firstChild())<br />
{<br />
// Get the first child's information before moving onto the next<br />
do<br />
{<br />
// Retrieve the name so we can use it to get<br />
// the GenBook's content later<br />
QString text = tk->getText();<br />
// Keep track of the information for custom implementation<br />
Class *item = storeItemInfoForLaterUse(parent, text);<br />
<br />
// If it has children, dive into it<br />
if (tk->hasChildren())<br />
getGenBookTOC(tk, item);<br />
}<br />
// Move onto the next child if any<br />
while (tk->nextSibling());<br />
// Move up one level in case one of the children had children<br />
tk->parent();<br />
}<br />
}<br />
</pre><br />
How you go about in implementing this is up to you.<br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7251DevTools:Code Examples2009-11-22T06:46:17Z<p>Underlined: /* Example Usage */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules are considered Generic Books. The most consistent way to differentiate between a Generic Book and a map or image module is to look for the configuration entry "Feature":<br />
<pre><br />
if (QString(module->getConfigEntry("Feature")) == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7250DevTools:Code Examples2009-11-22T05:19:15Z<p>Underlined: /* Example Usage */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules are considered Generic Books. The most consistent way to differentiate between a Generic Book and a map or image module is to look for the configuration entry "Feature":<br />
<pre><br />
if (module->getConfigEntry("Feature") == "Images")<br />
// do something ...<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=7249DevTools:Code Examples2009-11-22T05:17:44Z<p>Underlined: /* Get Modules Example(s) */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
'''Note:''' Map and image modules are considered Generic Books. The most consistent way to differentiate between a Generic Book and a map or image module is to look for the configuration entry "Feature":<br />
<pre><br />
module->getConfigEntry("Feature"); // should return "Images"<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6665DevTools:Code Examples2009-08-17T19:35:22Z<p>Underlined: /* Get Modules Example(s) */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
====== Example Usage ======<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
----<br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6664DevTools:Code Examples2009-08-17T19:34:31Z<p>Underlined: /* Get Biblical Book Names Example(s) */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
===== Example Usage =====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
----<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code #1 =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
But, of course, since it's not necessarily safe to assume that you would have an abbr.conf file lying around, the above example isn't necessarily practical. Nevertheless, hopefully, its existence provided some insight on [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]. The more proper way to obtain a list of Biblical, canonical book names is through the use of [http://www.crosswire.org/~ghellings/svnclassdocs/classVerseKey.html VerseKey]. VerseKey has a public member that stores the number of books for each testament&mdash;BMAX. BMAX[0] has the number of Old Testament books, and BMAX[1] has the number of New Testament books, which will be useful for use in a <tt>for</tt> loop. <br />
<br />
===== Code #2 =====<br />
<pre><br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
VerseKey vk;<br />
for (int b = 0; b < 2; b++)<br />
{<br />
// Set the Testament number to retrieve book names from that Testament.<br />
// Add 1 to b since the Testament numbers don't start at 0.<br />
vk.setTestament(b+1);<br />
for (int i = 0; i < vk.BMAX[b]; i++)<br />
{<br />
// Add 1 to i since the book numbers don't start at 0.<br />
vk.setBook(i+1);<br />
books << vk.getBookName();<br />
}<br />
}<br />
return books;<br />
}<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6618DevTools:Code Examples2009-08-03T03:31:32Z<p>Underlined: /* C++ */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
===== Example Usage =====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
----<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6617DevTools:Code Examples2009-08-03T03:29:22Z<p>Underlined: /* C++ */</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple", I mean something that can work within a static function if possible.<br />
<br />
== Examples ==<br />
<br />
=== C++ ===<br />
<br />
==== Get Modules Example(s) ====<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
===== Example Usage =====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
<br />
==== Get Biblical Book Names Example(s) ====<br />
Obtaining a list of the canonical books of the Bible doesn't necessarily require any SWORD classes (though in the following example we'll be using [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig]). A default SWORD installation installs the file <tt>abbr.conf</tt> at <tt>/usr/share/sword/locales.d</tt> on a Unix-like system (on Windows it may be located at <tt>C:\Program Files\CrossWire\The SWORD Project\locales.d</tt>). The syntax of the file is the same as any INI file. Therefore we just need to parse the file for the canonical books; so technically any configuration file parser that can parse INI files will do. The section we want to obtain from <tt>abbr.conf</tt> is called <tt>Text</tt>. (Again, the example uses a Qt4 class, [http://doc.trolltech.com/4.5/qstringlist.html QStringList].)<br />
<br />
===== Code =====<br />
<pre><br />
#include <QStringList><br />
#include <swconfig.h><br />
<br />
QStringList getBiblicalBooks()<br />
{<br />
QStringList books;<br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
ConfigEntMap::iterator it;<br />
for (it = config["Text"].begin(); it != config["Text"].end(); it++)<br />
{<br />
books << (*it).first.c_str();<br />
}<br />
<br />
return books;<br />
}<br />
</pre><br />
<br />
After obtaining all the Bible book names, you can obtain their abbreviations with [http://www.crosswire.org/~ghellings/svnclassdocs/classSWConfig.html SWConfig], again:<br />
<pre><br />
SWConfig config("/usr/share/sword/locales.d/abbr.conf");<br />
const char *GenAbbr = config["Text"]["Genesis"];<br />
</pre><br />
<br />
=== Python ===<br />
<br />
=== Java ===</div>Underlinedhttps://wiki.crosswire.org/index.php?title=Main_Page&diff=6615Main Page2009-08-02T04:24:18Z<p>Underlined: /* Development Tools */</p>
<hr />
<div>{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid green;padding-left:1em;padding-right:0.5em;background:#E4FFDF;padding-bottom:0.5em;" width="100%"|<br />
==Welcome to the CrossWire Developers' Wiki==<br />
Be sure to check out our [[Current Projects|current projects]] page to see how you might use your skills here at [http://crosswire.org/ CrossWire].<br />
<br />
Please look at our general [[Volunteers|volunteering]] page, the [http://www.crosswire.org/bugs bugs] database and/or assist endusers in the [http://www.crosswire.org/forums forums]<br />
<br />
Also, we have pages describing the [[Purpose Statement|purpose]] of our work and the [[About Us|CrossWire Bible Society]] itself.<br />
<br />
You can even come and chat with SWORD developers on IRC: [http://webchat.freenode.net/?randomnick=1&channels=sword&prompt=1 #sword] on FreeNode.<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
<br />
| style="background:#E8F1FF;border-style:solid;border-width:1px;border-color:#00ccFF;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==SWORD Modules==<br />
* List of Known [[Module Repositories]]<br />
* Information about Unicode [[Fonts]]<br />
* [[Module Requests]]<br />
<br />
==SWORD Frontends==<br />
* [[Frontends:BibleCS|The SWORD Project for Windows]]<br />
* [[Frontends:MacSword|MacSword]]<br />
* [[Frontends:Xiphos|Xiphos (GNOME)]] (formerly [[Frontends:GnomeSword|GnomeSword]])<br />
* [[Frontends:BibleDesktop|BibleDesktop (JSword)]]<br />
* [http://devel.bibletime.info BibleTime] (see also [[Frontends:KioSword|Kio-Sword]])<br />
* [http://bpbible.com BPBible (wxPython)]<br />
* [http://thegoan.com/firebible FireBible (JSword/FireFox)]<br />
* [http://www.swordwarrior.net SwordBible]<br />
* [http://www.crosswire.org/swordweb/ BibleTool]<br />
* [http://hurdygurdy.dyndns.org/maemosword/ Rapier] (for [http://maemo.org/ maemo] Internet tablets)<br />
* [http://www.kiyut.com/products/alkitab/ Alkitab Bible Study]<br />
* [http://pocketsword.net/ PocketSword] (for the iPhone)<br />
* A Frontend [[Frontends:FeatureList|Features Wishlist]]<br />
<br />
===No longer actively being developed===<br />
* [[Frontends:BibleStudy|BibleStudy (wxWidgets)]]<br />
* [[Frontends:Diatheke|Diatheke (CLI)]]<br />
* [[Frontends:SWORDReader|SWORDReader (PocketPC handhelds)]]<br />
<br />
===Platform-specific help===<br />
* [[Misc:EeePC|SWORD on the Asus EeePC]]<br />
<br />
|valign="top" bgcolor="#FFE8E8" style="border-style:solid;border-width:1px;border-color:#FF6060;padding-left:1em;padding-right:0.5em; padding-bottom:0.5em;" width="50%"|<br />
<br />
==Development Tools==<br />
* [[DevTools:SWORD|SWORD Engine (C++)]]<br />
* [[DevTools:JSword|JSword (Java)]]<br />
* [[:DevTools:Code Examples|Code Examples]]<br />
<br />
==Module Development==<br />
* How to Create [[DevTools:Modules|SWORD Modules]]<br />
* How to Create [[DevTools:confFiles|Module .conf Files]]<br />
* A Basic [[OSIS Tutorial]]<br />
* Guide to Writing [[OSIS Bibles]]<br />
* Guide to Writing [[OSIS Commentaries]]<br />
* Guide to Writing [[OSIS Genbooks]]<br />
* Guide to Writing [[ThML modules]]<br />
* Guide to Writing [[TEI Dictionaries]]<br />
* Guide to [[Converting SFM Bibles to OSIS]]<br />
* [[OpenOffice Export Filter for Genbooks]]<br />
* [[File Formats]] and related Utility Programs<br />
* [[Modules_in_the_beta_repository|Testing status of Beta modules]]<br />
* Guide to [[Creating and Maintaining a Module Repository]]<br />
* [[Non-CrossWire Text-Development Projects]]<br />
<br />
==Public Relations, Website, User assistance==<br />
* [[EnduserFAQ|FAQ]]<br />
* [[Project websites and domains]]<br />
* [[Help:Contents|Getting Help]]<br />
* [[Copyright|Copyright lobbying]]<br />
* [[Twitter|Sword Developers on Twitter]]<br />
|}<br />
{| cellspacing="1" width="100%"<br />
|- valign="top" <br />
|style="border: 1px solid gray;padding-left:1em;padding-right:0.5em;background:#E8E8E8;padding-bottom:0.5em;" width="100%"|<br />
<br />
==Getting Started in Wiki Collaboration==<br />
A Wiki is a place to share documentation and development information.<br />
* Anyone who has been a member for at least 4 days can edit a wiki once they have [[Special:Userlogin|logged in]].<br />
* If you are new to Wikis, consult the [http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide User's Guide] for information on using the wiki software.<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* You may experiment with Wiki using our [[CrossWire:Sandbox|Sandbox]].<br />
|}<br />
<br />
<br />
__NOTOC__</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6613DevTools:Code Examples2009-08-02T04:18:13Z<p>Underlined: moved Code Examples to DevTools:Code Examples:&#32;To keep things consistent.</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple" I mean something that can work within a static function if possible.<br />
<br />
= Examples =<br />
<br />
== C++ ==<br />
<br />
=== Get Modules Example(s) ===<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
==== Code ====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
==== Example Usage ====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
<br />
== Python ==<br />
<br />
== Java ==</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6612DevTools:Code Examples2009-08-02T04:14:15Z<p>Underlined: SWORD code examples for supported languages</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:Development tools]]<br />
<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple" I mean something that can work within a static function if possible.<br />
<br />
= Examples =<br />
<br />
== C++ ==<br />
<br />
=== Get Modules Example(s) ===<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
==== Code ====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
==== Example Usage ====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
<br />
== Python ==<br />
<br />
== Java ==</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6611DevTools:Code Examples2009-08-02T04:11:09Z<p>Underlined: SWORD code examples for supported languages</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
[[Category:DevTools]]<br />
<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple" I mean something that can work within a static function if possible.<br />
<br />
= Examples =<br />
<br />
== C++ ==<br />
<br />
=== Get Modules Example(s) ===<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
==== Code ====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
==== Example Usage ====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
<br />
== Python ==<br />
<br />
== Java ==</div>Underlinedhttps://wiki.crosswire.org/index.php?title=DevTools:Code_Examples&diff=6610DevTools:Code Examples2009-08-02T04:07:08Z<p>Underlined: SWORD code examples for supported languages</p>
<hr />
<div><!--<br />
***********************************************************************<br />
<br />
IF OTHERS ARE GOING TO EDIT THIS PAGE TO INCLUDE OTHER EXAMPLES,<br />
PLEASE TRY TO STICK TO THE FORMAT.<br />
<br />
***********************************************************************<br />
--><br />
<br />
This page was started to provoke developers who know how the SWORD API works to post simple, everyday code examples that anyone can use. By "simple" I mean something that can work within a static function if possible.<br />
<br />
= Examples =<br />
<br />
== C++ ==<br />
<br />
=== Get Modules Example(s) ===<br />
The following example is for obtaining modules that are installed in the user's SWORD repository. This example also makes slight use of the Qt4 GUI library. The following function takes one parameter, the type of the modules you want to retrieve. Unless stated otherwise, there are up to 4 different types to choose from:<br />
* "Biblical Texts"<br />
* "Commentaries"<br />
* "Lexicons / Dictionaries"<br />
* "Generic Books"<br />
==== Code ====<br />
<pre><br />
#include <QStringList><br />
#include <swmgr.h><br />
#include <swmodule.h><br />
<br />
QStringList getModules(const char* modType)<br />
{<br />
QStringList modules;<br />
SWMgr library;<br />
ModMap::iterator it;<br />
<br />
for (it = library.Modules.begin(); it != library.Modules.end(); it++)<br />
{<br />
SWModule *module = (*it).second;<br />
if (!strcmp(module->Type(), modType))<br />
modules << module->Name();<br />
}<br />
<br />
return modules;<br />
}<br />
</pre><br />
==== Example Usage ====<br />
<pre><br />
QStringList bibles = getModules("Biblical Texts");<br />
</pre><br />
<br />
== Python ==<br />
<br />
== Java ==</div>Underlined