0

我想解析像“1m2s3ms”这样的东西,其中每个部分都是可选的,例如“1m3ms”

qi::int_parser<sint64, 10> dec64;
const qi::rule<const char *, sint64()> nsRule = dec64 >> qi::lit("ns");
const qi::rule<const char *, sint64()> usRule = dec64 >> qi::lit("us");
const qi::rule<const char *, sint64()> msRule = dec64 >> qi::lit("ms");
const qi::rule<const char *, sint64()> sRule = dec64 >> qi::lit("s");
const qi::rule<const char *, sint64()> mRule = dec64 >> qi::lit("m");
const qi::rule<const char *, sint64()> hRule = dec64 >> qi::lit("h");
auto result = qi::parse(f, f + length, 
  -hRule >>
  -mRule >>
  -sRule >>
  -msRule >>
  -usRule >>
  -nsRule, h, m, s, ms, us, ns);

问题是,mRulemsRule非常相似,并且mRule在解析上面的示例时获胜。我可以使用任何指令吗?

4

0 回答 0