I'm trying to parse a file and have the data copied into a vector within a class object. I've taken the employee example and modified it to what I'm trying to do. The file being parsed looks like this (but more lines) ...
1 0.2 0.3 0.4
I've added a vector to struct employee and am getting assertion failures on the phrase_parse line.
static assertion failed: Attribute does not have the expected size.
static_assert(
^
I'm kind of thinking the expected size has something to do with the vector. Thoughts on where I'm going wrong?
namespace client {
namespace ast {
struct employee
{
int id;
std::vector<double> coords;
};
using boost::fusion::operator<<;
}}
BOOST_FUSION_ADAPT_STRUCT(
client::ast::employee,
(int, id)
(std::vector<double>, coords)
)
namespace client
{
namespace parser
{
namespace x3 = boost::spirit::x3;
namespace ascii = boost::spirit::x3::ascii;
using x3::int_;
using x3::double_;
x3::rule<class employee, ast::employee> const employee = "employee";
auto const employee_def =
int_ >> double_ >> double_ >> double_;
BOOST_SPIRIT_DEFINE(employee)
}
}
int main()
{
using boost::spirit::x3::ascii::space;
using client::parser::employee;
string fil("test-file.in");
mapped_file_source map(fil);
istringstream iss(map.data());
map.close();
client::ast::employee emp;
boost::spirit::istream_iterator iter(iss >> noskipws), eof;
phrase_parse(iter, eof, employee, space, emp);
// failure on above line
}