MCPcopy Create free account
hub / github.com/boostorg/parser / main

Function main

example/parsing_into_a_struct.cpp:23–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace bp = boost::parser;
22
23int main()
24{
25 std::cout << "Enter employee record. ";
26 std::string input;
27 std::getline(std::cin, input);
28
29 auto quoted_string = bp::lexeme['"' >> +(bp::char_ - '"') >> '"'];
30 auto employee_p = bp::lit("employee")
31 >> '{'
32 >> bp::int_ >> ','
33 >> quoted_string >> ','
34 >> quoted_string >> ','
35 >> bp::double_
36 >> '}';
37
38 employee record;
39 auto const result = bp::parse(input, employee_p, bp::ws, record);
40
41 if (result) {
42 std::cout << "You entered:\nage: " << record.age
43 << "\nsurname: " << record.surname
44 << "\nforename: " << record.forename
45 << "\nsalary : " << record.salary << "\n";
46 } else {
47 std::cout << "Parse failure.\n";
48 }
49}
50//]

Callers

nothing calls this directly

Calls 2

litFunction · 0.85
parseFunction · 0.70

Tested by

no test coverage detected