Yeah, now your skip parser (space) is eating the eol characters. Use qi::blank instead (which matches space and tab only).
Then it doesn't compile (msvc9.0).
#include
#include #include #include #include #include #include <string> namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii;
namespace details { struct sensor { int id; std::string type; int cam; int group; std::string name; int state; std::string regs; }; }
BOOST_FUSION_ADAPT_STRUCT ( details::sensor, (int, id) (std::string, type) (int, cam) (int, group) (std::string, name) (int, state) (std::string, regs) )
namespace details { template <typename Iterator> struct sensor_parser : qi::grammar
{ sensor_parser() : sensor_parser::base_type(start) { using qi::int_; using qi::lit; using qi::double_; using qi::lexeme; using qi::eol; using ascii::char_; text %= lexeme[+~char_("\r\n:")];
start %= int_ >> ':' >> text >> ':' >> int_ >> ':' >> int_ >> ':' >> text >> -(':' >> int_) >> -(':' >> text) >> eol ; }
qi::rule
text; qi::rule start; }; } int main() { typedef std::string::const_iterator iterator_type; typedef details::sensor_parser
sensor_parser; std::string str = "3:abcd:4:5:My name:6:33333333333\r\n"; details::sensor sens; std::string::const_iterator iter = str.begin(); std::string::const_iterator end = str.end();
sensor_parser g; using qi::blank; bool r = phrase_parse(iter, end, g, blank, sens); }
Why do you ask me to spoon feed answers to you? Everything should be in the error messages. Even more, the error you're getting points you to rule.hpp, line 245. And if you read the comment above that line you have the answer you need: // If you are seeing a compilation error here stating that the // forth parameter can't be converted to a qi::reference // then you are probably trying to use a rule or a grammar with // an incompatible skipper type. Anyway, the reason for your problem is that you're trying to use qi::blank for a grammar which was defined to use ascii::space_type. That can't work. HTH Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com