[sword-devel] Feature Complete Perl Interface

Chris Little sword-devel@crosswire.org
Sat, 21 Jul 2001 10:57:23 -0700


> I'll take a look ... right now I'm implementing a new 
> parse_verse_list() in Perl (the Sword one doesn't seem to 
> actually support ranges, even though there's an option for it).

It does parse verse lists.  Just use VerseKey::ParseVerseList and it
will return a listkey, containing a number of VerseKeys and SWKeys.  The
VerseKeys have UpperBound and LowerBound indicating the first and last
verse of the range.  The SWKeys are a single verse.  Check one of the
front ends for examples of implementation.  I believe the addvs utility
may have the simples to read implementation.
 
> How does language stuff work?  Can you just say
> systemLocaleMgr.setDefaultLocaleName(...) and then book names 
> and verses and everything will automagically come back in the 
> new language? Specifically, will the book[] array in VerseKey 
> work correctly?

In short, you need to do

		LocaleMgr::systemLocaleMgr.setDefaultLocaleName(locale);
		vk.setLocale(locale);

where locale is string containing the name of a locale and vk is a
VerseKey you're using.  (Repeat for all VerseKeys whose keys you
output.)
You can use 

		LocaleMgr lm = LocaleMgr::systemLocaleMgr;
		list<string> loclist =	lm.getAvailableLocales();
		list<string>::iterator li = loclist.begin();
		for (;li != loclist.end(); li++) {
		  cout << li->c_str();
		  cout << "\n";
		}

to output a list of locales installed on the system to your users.

I'm looking forward to trying this module out myself.  I have a feeling
it's not going to be much faster if I rig the diatheke CGI to use it,
though, since the biggest performance hit still comes with instantiating
SWMgr.  Do you (or anyone else) have any ideas for keeping SWMgr running
between CGI queries, aside from the idea I mentioned before of making a
Sword daemon to communicate using sockets?

--Chris