Wireshark-dev: Re: [Wireshark-dev] proto_tree -> proto_item
From: Luca Ceresoli <[email protected]>
Date: Mon, 23 Mar 2009 22:48:28 +0100
Sébastien Tandel ha scritto:

Therefore you could then do what you want with something like the following :
it = proto_tree_add_text(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor),
      ptvcursor_current_offset(cursor), length, "foo");
my_tree = ptvcursor_add_subtree_item(cursor, it, ...);
Thanks Sébastien,

that looks fine, except ptvcursor_add_subtree_item() is not (currently) declared in any header file, so that does not compile.
Apart from dumbly declaring it, I found this alternative:

 my_tree = ptvcursor_add_text_with_subtree(cursor, ..., "foo");
 my_item = proto_tree_get_parent(my_tree);
 /* ... */
 proto_item_set_text(my_item, "<%s>", my_string);

To me it looks safe and cleaner, am I missing anything?

Luca