[sword-devel] Prevent setKey from 'Leaking' into overlapping chapters/books

Alex S alexstets at gmail.com
Sat Jul 16 14:48:06 MST 2011


Ok, I did what Troy initially recommended, i.e. Checking if VerseKey.getVerse()>VerseKey.getMaxVerse, ditto for the chapter. If this is true, I used ListKey.SetToElement() and ListKey.Remove() to remove the invalid reference(s).

Works great.

....I can see the utility of wrapping for interactive GUI apps, but it's not useful for single command-line reference lookups, such as in the example I referred to originally.

Thanks for the help.

Regards,
Alex


On Jul 16, 2011, at 11:56 AM, "Troy A. Griffitts" <scribe at crosswire.org> wrote:

> Hey Alex,
> 
> Well, it depends on what behavior you want to happen when parsing an
> 'invalid verse reference'.
> 
> 1) Error() should be raised when parsing is completely misunderstood
> 
> 2) You can set VerseKey::Normalize to false, and arguably Error() should
> be raised when parsing chapters and verses outside of the versification
> system, but I'm not sure Error() is raised currently.
> 
> 3) if Normalize is false, you can check chapter and verse against
> VerseKey::getChapterMax() and VerseKey::getVerseMax() to see if it is
> outside the versification system.
> 
> Hope this is slightly useful.
> 
> You'll find the wrapping useful for things like:
> 
> // show a context window
> int contextWindow = 5;
> for (verseKey-=(contextWindow/2); !verseKey.Error() && contextWindow;
> verseKey++) ...
> 
> // show previous chapter
> verseKey.setChapter(verseKey.getChapter() - 1)
> ...
> 
> etc.
> 
> 
> Regarding more API help and more examples.  There is some documentation
> pulled from the comments in the code as doxygen here (but not as concise
> or helpful for a beginner as could be):
> 
> http://www.crosswire.org/~ghellings/1_6_2classdocs/
> 
> But I think your best bet is the examples/ and tests/ directory in the
> source tree.
> 
> If there is an example you would like to see, please shout and we can
> write one up together and improve the resources of example out.
> 
> Troy
> 
> 
> 
> 
> 
> 
> On 16/07/11 17:36, Alex S wrote:
>> Hi folks,
>> 
>> I'm just getting started with Sword, and Im working through the included examples. How can I prevent the verse parser from mapping a non valid reference to the next logical book/chapter?
>> 
>> For example if I run verserangeparse (in /examples) with "jn22:1" I get acts 1:1, which is the next logical chapter/verse since jn22 doesn't exist. 
>> 
>> Verserangeparse jn243:1 yields revelation 22:1
>> 
>> Any help? Sorry for the noob question...
>> 
>> Also, is there more extensive API documentation than the API primer on the crossword site?
>> 
>> 
>> Regards,
>> Alex
>> 
>> 
>> 
>> _______________________________________________
>> sword-devel mailing list: sword-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
> 
> 
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page



More information about the sword-devel mailing list