Re: Best way to work with Genbooks

"David \"Judah's Shadow\" Blue" <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <3755392.2qJbhSWcSR@brooks>
On Monday, March 4, 2024 4:32:43 PM EST David "Judah's Shadow" Blue wrote:
> Ok, I think I have a handle on how to generate the TOC. However, I'm not
> seeing a method in the API docs that would give me the text for a given TOC
> entry

Well I thought i had a handle on generating a TOC, but I'm only getting down 
one branch. I want to avoid recursion if I can, but I can't figure out how to 
get back up the tree to traverse down the next branch. If I have to use 
recursion I can, but I'd really like to avoid it. Here's my code so far.

std::string Genbook::getTOC() {
    sword::TreeKey *treeKey;
    sword::SWModule *mod;
    std::string toc = "";

    mod = swordLibrary->getModule(book.c_str());

    //Assume we don't have a TreeKey yet since we're just starting.
    treeKey = dynamic_cast<sword::TreeKey*>(mod->getKey());

    if(treeKey->firstChild()) {
        while(treeKey->nextSibling()) {
            toc += treeKey->getText();
            toc += "\n";
            if(treeKey->hasChildren()) {
                treeKey->increment();
            }
        }
    }

   return toc;

}



_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.