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

Alex S alexstets at gmail.com
Sat Jul 16 12:12:21 MST 2011


Troy, Thanks so much for the reply.

I added parser.setAutoNormalize(false) before the result = parser.ParseVerseList(....) in verserangeparser.cpp. Now when I run the program with an invalid reference like jn22:1, I don't get any output but it looks like it errors out, even if I have some valid references in the list, such as jn3:16,jn22:1. Could you give me a few pointers on how to skip over the bad values in the for loops and continue execution wit the valid references? 

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