Suppose I have the following string to parse:
"1.2, 2.0, 3.9"
and when I apply the following parser for it:
struct DataStruct
{
double n1, n2, n3;
};
BOOST_FUSION_ADAPT_STRUCT(DataStruct, (double, n1)(double, n2)(double, n3))
qi::rule<std::string::iterator, DataStruct()> data_ =
qi::double_ >> ','
>> qi::double_ >> ','
>> qi::double_;
auto str = "1.2, 2.0, 3.9";
auto it - str.begin();
if (qi::parse(it, str.end(), data_, res))
{
std::cout << "parse completed" << std::endl;
}
everything is ok, but when I suppose that instead of some double in my string I can get "null" (i.e. "1.2, null, 3.9") I want to assign 0 value to appropriate double value in DataStruct. Is any way to do this ?