Is it really necessary to wrap structs/classes with Boost.Fusion in order to use them with Boost.Spirit V2.x (especially Boost.Spirit.Qi)? I would much rather use semantic actions to assign to members. If my memory serves me well, this is the way it used to be done in V1.x...
The calculator example suggests that it should still be possible. So far, I haven't found a nice way to do it.
I would like to see how you would do it in the employee example. The following doesn't compile, but maybe there is some way to make it work:
template <typename Iterator>
struct employee_parser : qi::grammar<Iterator, employee(), ascii::space_type>
{
employee_parser() : employee_parser::base_type(start)
{
using qi::int_;
using qi::lit;
using qi::double_;
using qi::lexeme;
using ascii::char_;
quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
start =
lit("employee")
>> '{'
>> int_[px::bind(&employee::age, qi::_val) = qi::_1] >> ','
>> quoted_string[px::bind(&employee::surname, qi::_val) = qi::_1] >> ','
>> quoted_string[px::bind(&employee::forename, qi::_val) = qi::_1] >> ','
>> double_[px::bind(&employee::salary, qi::_val) = qi::_1]
>> '}'
;
}
qi::rule<Iterator, std::string(), ascii::space_type> quoted_string;
qi::rule<Iterator, employee(), ascii::space_type> start;
};
Nevermind, I still had the old fusion printing stuff in there. Funny how mistakes become so much easier to find after you have posted the question... :)
(Since this works, I must have made another error in the production code.)