[sword-devel] Understanding the structure of generic books and their relationship with TreeKey.

Ben Morgan benpmorgan at gmail.com
Mon Nov 2 22:28:49 MST 2009


It's probably easier to create a new TreeKey along the way, otherwise it
won't work properly (going to the parent at the end will lose the place in
the sibling iteration).

void getSectionsList(TreeKey tk, list l)
{
      do {
            l.append (tk->getText());
            if (tk->hasChildren())
            {
                 TreeKey new_tk = tk.clone();
                 new_tk->firstChild();
                 getSectionsList(new_tk, l);
                 delete new_tk;
            }
       } while (tk->nextSibling())
}

Untested code, of course...

God Bless,
Ben
-------------------------------------------------------------------------------------------
Multitudes, multitudes,
    in the valley of decision!
For the day of the LORD is near
    in the valley of decision.

Giôên 3:14 (ESV)

On 03/11/2009, Matthew Talbert <ransom1982 at gmail.com> wrote:
>
> This might be better. I'm probably still missing some logic.
>
> void getSectionsList(TreeKey tk, list l)
> {
>       l.append (tk->getText());
>       if tk->hasChildren()
>       {
>           tk->firstChild();
>           getSectionsList(tk, l);
>       }
>      while tk->nextSibling()
>      {
>           getSectionsList(tk, l);
>      }
>      tk->parent();
> }
>
> Matthew
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20091103/1340ee27/attachment-0001.html>


More information about the sword-devel mailing list