> The first two are localized to whatever language you have set for the engine This is great, because I want localizations.
> I am note sure I condone this behavior here :) TBH I was struggling to figure out exactly what that was trying to do (no offense, Tobias or whoever wrote it). > If you ever want to know how many Books, Chapters, Verses, etc. are available > in a reference system, these should serve that purpose: > VerseKey::getTestamentMax() > VerseKey::getBookMax(), once you set the testament > VerseKey::getChapterMax(), once you set the book > VerseKey::getVerseMax(), once you set the chapter Are the set{Book,Chapter,Verse} functions zero-indexed, and if so, do the get{Book,Chapter,Verse} functions reflect that? (Excuse my Bash scripting š) ________________________________ From: sword-devel <sword-devel-boun...@crosswire.org> on behalf of Troy A. Griffitts <scr...@crosswire.org> Sent: Tuesday, November 17, 2020 7:33 PM To: sword-devel@crosswire.org <sword-devel@crosswire.org> Subject: Re: [sword-devel] Getting info about books, chapters, and verses in a module Thank you Tobias, A few comments below: On 11/17/20 10:46 AM, Tobias Klein wrote: Hi Loren, This is how Iām doing it in node-sword-interface. 1) Getting the list of books in a module vector<string> ModuleHelper::getBookList(string moduleName) https://github.com/ezra-project/node-sword-interface/blob/master/src/sword_backend/module_helper.cpp#L70 A small comment, there are different styles of book names: VerseKey::getBookName() VerseKey::getBookAbbrev() VerseKey::getOSISBookName() The first two are localized to whatever language you have set for the engine, e.g., LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName("fr"); 2) Getting a map with the number of verses per chapter per book std::map<std::string, std::vector<int>> getBibleChapterVerseCounts(std::string moduleName); https://github.com/ezra-project/node-sword-interface/blob/master/src/sword_backend/module_helper.cpp#L92 I am note sure I condone this behavior here :) If you found a need to do something like this because you couldn't easily use the suggestions below, please let me know and maybe we can fix something or extend functionality to meet your needs. If you ever want to know how many Books, Chapters, Verses, etc. are available in a reference system, these should serve that purpose: VerseKey::getTestamentMax() VerseKey::getBookMax(), once you set the testament VerseKey::getChapterMax(), once you set the book VerseKey::getVerseMax(), once you set the chapter Please remember that each module might give different results, and creating a VerseKey object without specifying a reference system will create a KJV VerseKey. If you want the module-specific reference system, it is always good to do as your first example does and grab the current key, or use SWModule::createKey() to create a key specialized for the module-- which you'll need to delete when you are done using. Hope this helps. Thanks for the comments! There's an example here which goes into some of this and covers other things like VerseKey ranges: http://crosswire.org/svn/sword/trunk/examples/classes/lastVerseInChapter.cpp http://crosswire.org/svn/sword/trunk/examples/classes/verseranges.cpp Troy Best regards, Tobias Am 17.11.2020 um 04:43 schrieb Loren Burkholder <computersemiexp...@outlook.com<mailto:computersemiexp...@outlook.com>>: I was digging into the docs and found that a VerseKey can give some info about the book and chapter that it is in, and the numbers of books and chapters. This could be useful to me because I want to get a list of the books in a module, then load the number of chapters for the book and the number of verses for the selected chapter on-demand. However, I'm not completely sure how I should be doing this. Would the following pseudo-code be appropriate, or is there a different method that I should be using? m_books = someVar; // what should this do? key.setBook(m_books.currentIndex()); m_chapters = key.getChapterMax(); m_verses = key.getVerseMax(); setCurrentRef(m_books[index], m_chapters[index], m_verses[index]); I know that this isn't great pseudo code but it's what I came up with. Thanks, Loren _______________________________________________ sword-devel mailing list: sword-devel@crosswire.org<mailto:sword-devel@crosswire.org> http://crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page _______________________________________________ sword-devel mailing list: sword-devel@crosswire.org<mailto:sword-devel@crosswire.org> http://crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page
_______________________________________________ sword-devel mailing list: sword-devel@crosswire.org http://crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page