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