
#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;
}
