mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
Merge pull request #374 from Kojoley/ts_real_policies
ts_real_policies: Fixes and optimizations
This commit is contained in:
@@ -155,9 +155,9 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
}
|
||||
|
||||
// Thousands separated numbers
|
||||
template <typename Iterator, typename Attribute>
|
||||
template <typename Iterator, typename Accumulator>
|
||||
static bool
|
||||
parse_n(Iterator& first, Iterator const& last, Attribute& attr)
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& result)
|
||||
{
|
||||
using boost::spirit::qi::uint_parser;
|
||||
namespace qi = boost::spirit::qi;
|
||||
@@ -165,24 +165,18 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
uint_parser<unsigned, 10, 1, 3> uint3;
|
||||
uint_parser<unsigned, 10, 3, 3> uint3_3;
|
||||
|
||||
T result = 0;
|
||||
if (parse(first, last, uint3, result))
|
||||
{
|
||||
bool hit = false;
|
||||
T n;
|
||||
Iterator save = first;
|
||||
Accumulator n;
|
||||
Iterator iter = first;
|
||||
|
||||
while (qi::parse(first, last, ',') && qi::parse(first, last, uint3_3, n))
|
||||
while (qi::parse(iter, last, ',') && qi::parse(iter, last, uint3_3, n))
|
||||
{
|
||||
result = result * 1000 + n;
|
||||
save = first;
|
||||
hit = true;
|
||||
first = iter;
|
||||
}
|
||||
|
||||
first = save;
|
||||
if (hit)
|
||||
attr = result;
|
||||
return hit;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user