I have the following structure
struct MyStruct
{
char CODE;
char NAME[5];
};
I make it a fusion struct
BOOST_FUSION_ADAPT_STRUCT
(
MyStruct,
(char, MARKET_CODE)
(char, NAME[5])
)
My grammar is implemented as follow:
MyStruct_parser() : ticker_parser::base_type(start)
{
using qi::lexeme;
using ascii::char_;
a_word %= lexeme[+(char_)];
start %= a_word >> a_word;
}
qi::rule<Iterator, std::string(), ascii::space_type> quoted_string;
qi::rule<Iterator, Ticker(), ascii::space_type> start;
Unfortunately it does not compile. Now I use std::string instead of char[5] I have no problem. Can you please tell me how to tell Spirit to read char[5]?
Thank you
You can supply custom attribute transformations using
boost::spirit::traits::transform_attribute<>
:See it Live On Coliru or indeed Live for C++03
Prints
in both the c++11 and c++03 versions