我使用Boost 1.44,Spirit分析器可以很好地进行数值解析,但对于字符串解析来说真的很棘手。我试图解析一个字符串,使用多个分隔符分割:',',';'要么 ' '。它非常适用于数字,当我这样做(其中VECT =矢量<双重>):Boost Spirit基于语法分割的字符串
qi::parse(first,last,double_ >> *(',' >> double_ | ' ' >> double_ | ';' >> double_),
VECT,空间);
然而,当我修改用于使用VECT =矢量<字符串>串的语法,
+char_ >> *(',' >> +char_ | ' ' >> +char_ | ';' >> +char_)
我得到以下错误:
/usr/include/boost/spirit/home/qi/detail/assign_to.hpp:109:13: error: invalid conversion from ‘char’ to ‘const char*’/usr/include/boost/spirit/home/qi/detail/assign_to.hpp:109:13: error: initializing argument 1 of ‘std::basic_string<_CharT, _Traits,_Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’
我缩小的误差是所述第一+ char_在语法语法中被视为一系列字符而不是字符串。有没有办法解决这个问题?
谢谢
另请参阅http://stackoverflow.com/questions/7436481/how-to-make-my-split-work-only-on-one-real-line-and-be-capable-to-skeep-quoted -pa/7462539#7462539 – sehe