开发者

boost property tree, iterators to an element for inserting?

开发者 https://www.devze.com 2023-04-08 22:24 出处:网络
I\'ve searched a lot through the boost manual, and the internet, as I believe it is quite a standard feature?

I've searched a lot through the boost manual, and the internet, as I believe it is quite a standard feature?

Well I'm looking into "merging" property trees. - I noticed the function insert, and I hope I can merge trees with this?开发者_如何学运维 Below is the line which I am trying to get working:

base.insert(base.get_child("BRANCH"), t);

base and t are "property trees", base has as (one of many) branch "BRANCH". Now I wish to insert t into this branch?

More specifically: how can I get an iterator to "element" if I know that element by name?


You can get an iterator to an element using the begin() method:

  base.get_child("BRANCH").begin();

In order to insert every element in t on that position, you should use:

base.insert(base.get_child("BRANCH").begin(), t.begin(), t.end());

If t contains one parent node or you only want to insert the first node, you can use:

base.insert(base.get_child("BRANCH").begin(), t.front());
0

精彩评论

暂无评论...
验证码 换一张
取 消