Пример #1
0
void cleanup(boost::property_tree::basic_ptree<std::basic_string<Ch>, std::basic_string<Ch> > & tree)
{
    bool hasElements = false;
    for(typename boost::property_tree::basic_ptree<std::basic_string<Ch>, std::basic_string<Ch> >::iterator i = tree.begin(), end = tree.end(); i != end; ++i)
    {
        if(!hasElements && i->first != boost::property_tree::xml_parser::xmlattr<Ch>() && i->first != boost::property_tree::xml_parser::xmltext<Ch>())
            hasElements = true;
        cleanup(i->second);
    }
    if(hasElements)
        tree.data().clear();
}
void getVectorOfDatesFromBasicPTree(const boost::property_tree::basic_ptree<T_key, T_data>&  pt,        // input
							     const std::string&                                       itemKey,   // input
							     std::vector<Date>&                                       vDates)    // output
{
	boost::property_tree::basic_ptree<T_key, T_data>::const_iterator iter = pt.begin();

	while(iter != pt.end())
	{
		if(iter->first == itemKey)
		{
			writeDiagnostics("Found date in property tree: " + toString( iter->second.data()),
				             high, "getVectorOfDatesFromBasicPTree");
			vDates.push_back(stringToDate( iter->second.data(), getConfig()->getDateFormat()));
		}
		else
		{
			writeDiagnostics("In pTree, found: " + toString(iter->first.data()) + "\nwith: " + toString(iter->second.data()),
			                 high, "getVectorOfDatesFromBasicPTree");
		}

		iter++;
	}    
}