Boost logo

Boost :

Subject: Re: [boost] [gil::io] Feedback for scanline_read_iterator
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2013-02-18 15:02:01

Christian Henning wrote:
> The difference to a "normal" iterator is that I have two distinct
> functionalities that I need to squeeze into the standard iterator
> interface.

I don't follow; what two functionalities?

> I would like to hear your opinion on how this could be
> accomplished!

I imagine your line-by-line reading iterator would look something like (PSEUDO-CODE!!!):

class line_by_line_iterator {
   buffer_t& buffer;

   const buffer_t& operator*() const { return buffer; }
   void operator++() { format_specific_read_one_line_into(buffer); }

I'd do it using iterator_facade.

A case that this fails to manage efficiently is when your
format-specific implementation has an efficient way to skip forward
without actually decoding. This is not something that I've ever had to
worry about, but I think you could do it easily enough by adding a flag
and doing the read lazily in operator*.

Regards, Phil.

Boost list run by bdawes at, gregod at, cpdaniel at, john at