[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>
<br>I also have a few questions about SWModule. In the Sword API Primer
this example is given:
<p> SWMgr manager; // create a default manager
that looks in the current directory for mods.conf
<br> ModMap::iterator modIterator;
<p> // Loop thru all installed modules and print out
information
<br> for (modIterator = manager.Modules.begin(); modIterator
!= manager.Modules.end(); modIterator++) {
<br> string modName
= (*modIterator).first; // mod.conf section name (stored in module->Name())
<br> SWModule *module =
(*modIterator).second;
<br> if ((!strcmp(module->Type(),
"Biblical Texts")) {
<br>
module->SetKey("jas 1:19");
<br>
cout << modName << ": " << (const char *) *module <<
"\n";
<br> }
<br> }
<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<string,string,less<string>
> somevar, I can access members like this: somevar[string]
<br>According to the Sword API Primer, ModMap is defined thus: typedef
map <string, SWModule *, less<string> > ModMap
<br>I would think I could reference an SWModule like thus:
<br>string version("KJV");
<br>SWModule *module = ModMap[&version];
<br>But the compiler complains: parse error before `['
<br>
<pre>--
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Tim Hawes
***Althusius.net***
<a href="http://Althusius.net">http://Althusius.net
</a> 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</pre>
<p> </html>
--------------07429D1B12C3BD51D7E00B4D--