无法对codesynthesis xml类型执行操作

时间:2013-09-08 22:12:52

标签: c++ xml xsd

我的xml文件中有元素dateselection,blackscholes和volatility,我想检查这些的值,尝试使用std :: cout打印出内容给我构建错误,我也想检查一下元素存在于xml文件中,例如if(blackscholes.exists())。代码综合中是否存在此类功能?

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();

我还可以将结束日期转换为boost / date_time / gregorian / gregorian类型吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

查看接口文件(生成的hxx存根)我发现以下类型映射到xml库等效于strings和bool ::: xml_schema :: string,:: xml_schema :: date,vanillaoption :: blackscholes_type。名称可能因架构而异,但使用这些名称来处理和打印出适用于我的值(使用:: xml前缀搜索名称)。要检查可选字段,必须将元素放在“choice”中,stubs将为每个名为“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
    }
}