Boost logo

Boost Users :

Subject: Re: [Boost-users] [xpressive] Using it with input iterators or how far the backtracing will go back
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-11-08 21:15:06


On 11/9/2010 3:03 AM, Eric Niebler wrote:
> (cross-posting to spirit-devel)
>
> On 11/8/2010 12:36 PM, Alex Dubov wrote:
>> Nat Linden<nat<at> lindenlab.com> writes:
>>> Once upon a time, the Serialization library came with backtracking input
>>> iterators used to parse XML input files with Spirit. I briefly glanced over
>>> more recent Serialization documentation without spotting them. Do they still
>>> exist?
>>
>> Yes, in a way.
>> Spirit only requires forward iterators, not bidi ones, like xpressive. Input
>> iterators can be adapted to become forward ones in a fairly straightforward
>> way, and indeed, spirit has a customizable multi_pass iterator adapter to do
>> just that.
>>
>> Up until now I thought spirit to be an overkill for my stuff, but I'm
>> considering using it now.
>
> Just hazarding a guess here, but the multi_pass_iterator probably works
> by caching all the read data so far. Otherwise, how would it support
> making a copy of the begin iterator and dereferencing it at a later
> point in time? If that solution wasn't good enough for you before, you
> probably don't want multi_pass_iterator+Spirit.
>
> Can the Spirit guys chime in on this?

The multi_pass iterator uses a sliding window that can be flushed when
you reach a deterministic point, a point of no return where back-tracking
is no longer an option. In this case, saved iterators are invalidated.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net