私はboost::spirit
を勉強しようとしています。たとえば、一連の単語を解析してvector<string>
にしようとしています。boost :: spiritを使用して一連の単語をベクトルに解析する方法は?
'thisisatest'
が、私はそれぞれの単語が個別にマッチしている次の出力、望んでいた:
'this'
'is'
'a'
'test'
可能であれば、私は」を私にこの出力を与える
#include <boost/spirit/include/qi.hpp>
#include <boost/foreach.hpp>
namespace qi = boost::spirit::qi;
int main() {
std::vector<std::string> words;
std::string input = "this is a test";
bool result = qi::phrase_parse(
input.begin(), input.end(),
+(+qi::char_),
qi::space,
words);
BOOST_FOREACH(std::string str, words) {
std::cout << "'" << str << "'" << std::endl;
}
}
:私はこれを試してみましたこの単純なケースのために私自身のサブクラスを定義する必要を避けるのが好きです。
よく説明されています、+1 – sehe