[sword-devel] Learning the Sword API

Tim Hawes sword-devel@crosswire.org
Tue, 06 Feb 2001 16:54:07 -0500


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


I also have a few questions about SWModule. In the Sword API Primer this
example is given:

    SWMgr manager;  // create a default manager that looks in the
current directory for mods.conf
    ModMap::iterator modIterator;

    // Loop thru all installed modules and print out information
    for (modIterator = manager.Modules.begin(); modIterator !=
manager.Modules.end(); modIterator++) {
        string   modName  = (*modIterator).first;  // mod.conf section
name (stored in module->Name())
        SWModule *module  = (*modIterator).second;
        if ((!strcmp(module->Type(), "Biblical Texts")) {
            module->SetKey("jas 1:19");
            cout << modName << ": " << (const char *) *module << "\n";
        }
    }

I have no problem with this, but it appears that if I wanted to show a
range of verses (all verses in James Chapter 1, for example) I cannot
create a VerseKey object for the SWModule like I did for RawText.
VeseKey *mykey = module->CreateKey() causes a segfault.

The other question I have, and this relates to my unclear understanding
of STL, is there a way to call a particular ModMap without traversing
all available ModMaps?
I know that if I create a map as thus: map<string,string,less<string> >
somevar, I can access members like this: somevar[string]
According to the Sword API Primer, ModMap is defined thus: typedef map
<string, SWModule *, less<string> > ModMap
I would think I could reference an SWModule like thus:
string version("KJV");
SWModule *module = ModMap[&version];
But the compiler complains:  parse error before `['


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

  Tim Hawes

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

          thawes@althusius.net

---------------------------------------------------------
 Toleration is an inner personal disposition, is a
fundamental requirement of being human and of living
together in society . . .When toleration becomes
indifference, it is ruined.                -Van Ruler





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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<br>I also have a few questions about SWModule. In the Sword API Primer
this example is given:
<p>&nbsp;&nbsp;&nbsp; SWMgr manager;&nbsp; // create a default manager
that looks in the current directory for mods.conf
<br>&nbsp;&nbsp;&nbsp; ModMap::iterator modIterator;
<p>&nbsp;&nbsp;&nbsp; // Loop thru all installed modules and print out
information
<br>&nbsp;&nbsp;&nbsp; for (modIterator = manager.Modules.begin(); modIterator
!= manager.Modules.end(); modIterator++) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp;&nbsp; modName&nbsp;
= (*modIterator).first;&nbsp; // mod.conf section name (stored in module->Name())
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SWModule *module&nbsp; =
(*modIterator).second;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((!strcmp(module->Type(),
"Biblical Texts")) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
module->SetKey("jas 1:19");
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cout &lt;&lt; modName &lt;&lt; ": " &lt;&lt; (const char *) *module &lt;&lt;
"\n";
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; }
<p>I have no problem with this, but it appears that if I wanted to show
a range of verses (all verses in James Chapter 1, for example) I cannot
create a VerseKey object for the SWModule like I did for RawText. VeseKey
*mykey = module->CreateKey() causes a segfault.
<p>The other question I have, and this relates to my unclear understanding
of STL, is there a way to call a particular ModMap without traversing all
available ModMaps?
<br>I know that if I create a map as thus: map&lt;string,string,less&lt;string>
> somevar, I can access members like this: somevar[string]
<br>According to the Sword API Primer, ModMap is defined thus: typedef
map &lt;string, SWModule *, less&lt;string> > ModMap
<br>I would think I could reference an SWModule like thus:
<br>string version("KJV");
<br>SWModule *module = ModMap[&amp;version];
<br>But the compiler complains:&nbsp; parse error before `['
<br>&nbsp;
<pre>--&nbsp;
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

&nbsp; Tim Hawes

&nbsp;&nbsp;&nbsp;&nbsp; ***Althusius.net***
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://Althusius.net">http://Althusius.net

</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thawes@althusius.net

---------------------------------------------------------
&nbsp;Toleration is an inner personal disposition, is a
fundamental requirement of being human and of living
together in society . . .When toleration becomes
indifference, it is ruined.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Van Ruler</pre>
&nbsp;
<p>&nbsp;</html>

--------------07429D1B12C3BD51D7E00B4D--