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循环遍历
GitHubID:shiyi23
践行 活在当下 的理念