|
Boost Users : |
Subject: [Boost-users] How to add child tree into an existing tree.
From: Anil Jangam (anilj.mailing_at_[hidden])
Date: 2016-03-24 04:43:53
Hi,
I have the following property tree.
propset1
{
prop1 2
prop2 5
prop3 60
prop4 7
}
I am trying to add couple of child trees to this so that the resulting
property tree would look like below.
propset1
{
prop1 2
prop2 5
prop3 60
prop4 5
childset1
{
child1prop1 4
child1prop1 6
child1prop1 9
}
childset2
{
child2prop1 2
child2prop1 6
child2prop1 7
}
}
I wrote the following code.
// Add General config
pt::ptree propset1;
propset1.put("propset1.prop1", 2);
propset1.put("propset1.prop2", 5);
propset1.put("propset1.prop3", 60);
propset1.put("propset1.prop4", 7);
// Add childset1 config
pt::ptree childset1;
childset1.add("child1prop1", 4);
childset1.add("child1prop2", 6);
childset1.add("child1prop3", 9);
propset1.add_child("childset1", childset1);
// Add childset2 config
pt::ptree childset2;
childset2.add("child2prop1", 2);
childset2.add("child2prop2", 6);
childset2.add("child2prop3", 7);
propset1.add_child("childset2", childset2);
However the above code is resulting into below property tree.
propset1
{
prop1 2
prop2 5
prop3 60
prop4 5
childset1
{
child1prop1 4
child1prop1 6
child1prop1 9
}
}
propset1
{
prop1 2
prop2 5
prop3 60
prop4 5
childset2
{
child2prop1 2
child2prop1 6
child2prop1 7
}
}
Can someone please suggest what is correct use of API?
/anil
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net