std::string parseBond(std::string& fileName)
{
boost::property_tree::ptree ptree_root;
try {
boost::property_tree::read_xml(fileName, ptree_root);
}
catch (std::exception& e)
{
return e.what();
};
auto Bonds = ptree_root.get_child("IMIXML");
BOOST_FOREACH(auto &Bond, Bonds)
{
CBond singleBond;
memset(&singleBond, 0, sizeof(singleBond));
try {
getSingleBond(Bond.second, &singleBond);
auto pOld = memdb->m_BondFactory->getByBondIDIndex(singleBond.BondID, singleBond.MarketType);
memdb->m_BondFactory->addOrUpdate(pOld, &singleBond, 0);
}
catch (std::exception& e)
{
return e.what();
}
}
return "";
}
重点注意看getChild和for循环遍历
标签:XML,std,范式,auto,ptree,return,boost,singleBond From: https://www.cnblogs.com/huangshiyi/p/16932182.html