Boost logo

Boost :

Subject: Re: [boost] [tokenizer] tokenizing by strings rather than chars
From: Michael Caisse (boost_at_[hidden])
Date: 2011-05-27 13:57:04


On 05/27/2011 10:06 AM, Stewart, Robert wrote:
> Andrzej Krzemienski wrote:
>
>> I want to parse numbers separated by "new-lines", however, on
>> my windows system, a "new-line" is represented by two
>> consecutive characters: 13, 10 (or in other words by string
>> "\n\r"). So, only if I encounter a sequence of these two chars
>> do I want to cut the token.
>>
> Spirit.Qi would do that handily. Something like this should work:
>
> namespace qi = boost::spirit::qi;
> std::vector<int> data;
> qi::phrase_parse(input.begin(), input.end(), qi::int_, qi::eol, data);
>
> _____
>

Small correction (missing the kleen):

qi::phrase_parse(input.begin(), input.end(), *qi::int_, qi::eol, data);

-- 
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk