#include <iostream>
#include <string>
#include <vector>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_parse.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
class TEST
{
public:
int x;
int y;
int z;
};
BOOST_FUSION_ADAPT_STRUCT(TEST, (int, x)(int, y)(int, z))
int main(int argc, char ** argv)
{
using namespace std;
namespace q = boost::spirit::qi;
string text = "val = [111,222,1][333,444,2][555,666,3] [ 777, 888 , -4]\n";
vector<TEST> testvec;
q::phrase_parse(text.begin(), text.end()
, q::lit("val") >> "=" >> +('[' >> q::int_ >> ',' >> q::int_ >> ',' >> q::int_ >> ']')
, q::ascii::space, testvec);
for (int i(0), l(testvec.size()); i < l; ++i) {
cout << i << " : " << testvec[i].x << "," << testvec[i].y << "," << testvec[i].z << endl;
}
return 0;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KCiNpbmNsdWRlIDxib29zdC9zcGlyaXQvaW5jbHVkZS9xaS5ocHA+CiNpbmNsdWRlIDxib29zdC9zcGlyaXQvaW5jbHVkZS9xaV9wYXJzZS5ocHA+CiNpbmNsdWRlIDxib29zdC9mdXNpb24vYWRhcHRlZC9zdHJ1Y3QvYWRhcHRfc3RydWN0LmhwcD4KCmNsYXNzIFRFU1QKewpwdWJsaWM6CglpbnQgeDsKCWludCB5OwoJaW50IHo7Cn07CgpCT09TVF9GVVNJT05fQURBUFRfU1RSVUNUKFRFU1QsIChpbnQsIHgpKGludCwgeSkoaW50LCB6KSkKCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqIGFyZ3YpCnsKCXVzaW5nIG5hbWVzcGFjZSBzdGQ7CgluYW1lc3BhY2UgcSA9IGJvb3N0OjpzcGlyaXQ6OnFpOwoKCXN0cmluZyB0ZXh0ID0gInZhbCA9IFsxMTEsMjIyLDFdWzMzMyw0NDQsMl1bNTU1LDY2NiwzXSAgICAgWyA3NzcsICAgODg4ICA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