C++ 无法对codesynthesis xml类型执行操作
我的xml文件中有dateselection、blackscholes和volatility元素,我想检查这些元素的值,尝试使用std::cout打印内容会给我生成错误,我还想检查xml文件中是否存在这些元素,例如(blackscholes.exists())。这样的功能是否存在于代码合成中C++ 无法对codesynthesis xml类型执行操作,c++,xml,xsd,C++,Xml,Xsd,我的xml文件中有dateselection、blackscholes和volatility元素,我想检查这些元素的值,尝试使用std::cout打印内容会给我生成错误,我还想检查xml文件中是否存在这些元素,例如(blackscholes.exists())。这样的功能是否存在于代码合成中 dateselection& date = i->dateselection(); const xsd::cxx::tree::date<char,simple_type>&
dateselection& date = i->dateselection();
const xsd::cxx::tree::date<char,simple_type>& end = date.enddate();
const xsd::cxx::tree::sequence<bool, true>& black = i->blackscholes();
const xsd::cxx::tree::sequence<bool, true>& volatility = i->volatility();
dateselection&date=i->dateselection();
const xsd::cxx::tree::date&end=date.enddate();
constxsd::cxx::tree::sequence&black=i->blackscholes();
const xsd::cxx::tree::sequence&volatility=i->volatility();
我还可以将结束日期转换为boost/date\u time/gregorian/gregorian类型吗
提前感谢查看接口文件(生成的hxx存根),我发现以下类型映射到xml库,相当于字符串和bool:::xml_schema::string,::xml_schema::date,vanillaoption::blackscholes_type。名称可能因模式而异,但使用这些名称来处理和打印值对我来说很有用(搜索带有::xml前缀的名称)。要检查可选字段,必须将元素放在“choice”中,存根将为每个元素生成一个名为“present”的函数。您可以使用它来确定配置文件中是否存在元素。比如说
for(quantoptions::vanillaoption_iterator i (optionConfig->vanillaoption().begin()); i != optionConfig->vanillaoption().end(); ++i)
{
dateselection& date = i->dateselection();
::xml_schema::string symbol = i->symbol();
::xml_schema::date &endDate = date.enddate();
if(i->blackscholes().present())
{
//do whatever
}
}
请提供更多信息:架构文件、XML文件、错误消息。如果文件太大,无法包含在问题中,请尝试仅显示文件的相关部分。