[sword-devel] Learning the Sword API

Tim Hawes sword-devel@crosswire.org
Mon, 05 Feb 2001 07:07:14 -0500


--------------6D51CBD3F2D0E16C6416A5FC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I have written a small program to better understand the Sword API.
Essentially this is suppose to find a particular module, set a key and
display the bible text in that key.


#include <iostream>
using namespace std;

#include <swmgr.h>
#include <rawcom.h>
#include <rawtext.h>
#include <versekey.h>

int main(int argc, char **argv)
   {
      SWMgr manager;  // create a default manager that looks
                      // in the current directory for mods.conf
      SWModule *module;

      ModMap::iterator I = manager.Modules.begin();

      while(I != manager.Modules.end())
         {
            string   modName  = (*I).first;
            // SWModule *tempmod  = (*modIterator).second;

            if (modName == "AKJV")
               {
                  module = (*I).second;
               }
            I++;
         }

      module->SetKey("jas 1:19");
      cout << module->Type() << endl
           << module->Name() << ": "
           << (const char *) module << endl;

      return 0;
   }

Can anyone tell me why this does not display the key contents? Also, is
there a way to find a particular module without having to cycle through
the entire ModMap to find it (I am green around the ears in C++)?

--
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  Tim Hawes

     ***Althusius.net***
      http://Althusius.net

          thawes@althusius.net

---------------------------------------------------------

--------------6D51CBD3F2D0E16C6416A5FC
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I have written a small program to better understand the Sword API. Essentially
this is suppose to find a particular module, set a key and display the
bible text in that key.
<br>&nbsp;
<pre>#include &lt;iostream>
using namespace std;

#include &lt;swmgr.h>
#include &lt;rawcom.h>
#include &lt;rawtext.h>
#include &lt;versekey.h>


int main(int argc, char **argv)
&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SWMgr manager;&nbsp; // create a default manager that looks
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // in the current directory for mods.conf&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SWModule *module;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ModMap::iterator I = manager.Modules.begin();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(I != manager.Modules.end())
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp;&nbsp; modName&nbsp; = (*I).first;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // SWModule *tempmod&nbsp; = (*modIterator).second;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (modName == "AKJV")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; module = (*I).second;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; module->SetKey("jas 1:19");&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; module->Type() &lt;&lt; endl
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; module->Name() &lt;&lt; ": "
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; (const char *) module &lt;&lt; endl;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;
&nbsp;&nbsp; }</pre>
Can anyone tell me why this does not display the key contents? Also, is
there a way to find a particular module without having to cycle through
the entire ModMap to find it (I am green around the ears in C++)?
<p>--&nbsp;<br>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\<br>
<br>
&nbsp; Tim Hawes<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; ***Althusius.net***<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://Althusius.net">http://Althusius.net</A><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thawes@althusius.net<br>
<br>
---------------------------------------------------------<br>
<BR></html>

--------------6D51CBD3F2D0E16C6416A5FC--