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: sword-devel@crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to