Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-06-01 21:29:36


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uisebatkh.fsf_at_boost-consulting.com...
> slavek.f.kuzniar_at_[hidden] writes:
>
> > The previous version available at
> > http://www.xmission.com/~turkanis/iostreams/.
> >
> > I've since made some major simplifications and improvements, and
am
> > scrambing to update the docs. It now contains support for
> > memory-mapped files (from Craig Henderson) and for compression and
> > decompression in the zlib, gzip and bzip2 formats.
>
> The thing I wanted recently was an "offset streambuf", an adapter
> for another streambuf that presents an "offset view" (i.e. with
> respect to seeking) of the underlying streambuf.

This sounds like it might be a job for a 'SeekableFilter' -- something
I included support for even though I didn't have any use for it. The
interface for a seekable filter is basically this:

    struct seekable_filter {
         // some typedefs
         streamsize read(char* s, streamsize n, streambuf& next);
         void write(const char* s, streamsize n, streambuf& next);
         streamoff seek(streamoff off, ios_base::seekdir way,
streambuf& next);
    };

Here 'next' is the streambuf being filtered. Any number of filters can
be chained.

You take a filtering_streambuf<seekable>, add your filter, then add
the underlying streambuf:

     filtering_streambuf<seekable> filtered;
     filtered.push(seekable_filter());
     filtered.push(sbuf);

What exactly did you want the offset streambuf to do? I'd be
interested to see if I can implement it using the above framework. It
would be a nice example of a concept which so far I haven't used.

Jonathan


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