From fcbb91a00e02f65532ed516cb780b75918b60dfb Mon Sep 17 00:00:00 2001 From: jakepruitt Date: Wed, 23 Sep 2015 12:08:50 -0700 Subject: [PATCH] Add int list parser --- src/svg/svg_parser.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index ec1f4d857..52840c8a9 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -157,6 +157,25 @@ double parse_double_optional_percent(T & error_messages, const char* str, bool & return val; } +template +bool parse_integer_list(T & error_messages, const char* str, int* list) +{ + using namespace boost::spirit::qi; + using boost::phoenix::ref; + qi::_1_type _1; + qi::int_type int_; + + if (!parse(str, str + std::strlen(str), int_[ref(list[0])=_1] >> ' ' | ',' + >> int_[ref(list[1])=_1] >> ' ' | ',' + >> int_[ref(list[2])=_1] >> ' ' | ',' + >> int_[ref(list[3])=_1])) + { + error_messages.emplace_back("failed to parse list of integers from " + std::string(str)); + return false; + } + return true; +} + bool parse_style (char const* str, pairs_type & v) { using namespace boost::spirit::qi;