#include #include #include #include #include struct test_a { boost::uint16_t x; boost::uint16_t y; }; BOOST_FUSION_ADAPT_STRUCT ( test_a, (boost::uint16_t, x) (boost::uint16_t, y) ) struct test_b { boost::uint8_t u; }; BOOST_FUSION_ADAPT_STRUCT ( test_b, (boost::uint8_t, u) ) typedef boost::variant variant_type; struct outer { boost::uint32_t i; variant_type j; }; BOOST_FUSION_ADAPT_STRUCT ( outer, (boost::uint32_t, i) (variant_type, j) ) template struct test_b_parser: boost::spirit::qi::grammar { test_b_parser(): test_b_parser::base_type(start) { using boost::spirit::byte_; start = ( byte_ ) ; } boost::spirit::qi::rule start; }; template struct test_a_parser: boost::spirit::qi::grammar { test_a_parser(): test_a_parser::base_type(start) { using boost::spirit::big_word; start = ( big_word >> big_word ) ; } boost::spirit::qi::rule start; }; template struct outer_parser: boost::spirit::qi::grammar { outer_parser(): outer_parser::base_type(start) { using boost::spirit::byte_; using boost::spirit::big_word; using boost::spirit::big_dword; start = ( big_dword ) >> ((big_word(0) >> ap) | (big_word(4) >> bp)) ; } test_a_parser ap; test_b_parser bp; boost::spirit::qi::rule start; }; int main() { outer_parser dp; return 0; }