Ads removed from the pastie. \o/
Running costs stayed. :-(
Donations welcome!
Bitcoin: |
1QC38uPBSy7WSYz1whM5SYTHAdhqkN6o8V |
Ethereum: |
0x0855778a6181a69cc7d5d08c71c4f5846010eb67 |
Litecoin: |
LbgSLsAbgbZBU2Ksg4vwuKHK8dAbJESi49 |
Verge: |
D8fo1fszrNmUK4kfQW5owhYMv3osPvgn2g |
Paste ID: |
# TPfHg |
Date posted: |
Mon, 19 Nov 2012 10:48:40 +0000 |
Date of expiration: |
never (permanent entry) |
Description: |
Reading a boost::property_tree::ptree recursively and make it an URL query string |
string readPropertyTreeRecursive( boost::property_tree::ptree& rptree, string& prefix )
{
// Leaf
string ret;
if( rptree.size() == 0 )
{
ret = prefix + "=" + rptree.data() + "&";
return ret;
}
// Subtree
else
{
BOOST_FOREACH( boost::property_tree::ptree::value_type& child, rptree )
{
string subprefix;
// Avoid adding a leading dot
if( !prefix.empty() )
subprefix = prefix + std::string( "." ) + child.first.data();
else
subprefix = child.first.data();
// Build up return string recursively
ret += readPropertyTreeRecursive( child.second, subprefix );
}
}
return ret;
}