Boost logo

Boost Users :

Subject: [Boost-users] [iostreams] tellg not supported on devices / filters that aren't seekable
From: Sebastian Karlsson (sairony_at_[hidden])
Date: 2010-09-30 10:26:56


I find it inconvenient that tellg isn't supported on filters / devices
that isn't seekable, since tellg doesn't really seek but simply
reports the current read head position. Here follows some example code
that will throw due to this:

#include <ostream>
#include "boost/iostreams/categories.hpp"
#include "boost/iostreams/filtering_stream.hpp"
#include "boost/iostreams/filter/zlib.hpp"

int main()
{
        boost::iostreams::filtering_stream< boost::iostreams::input > strm( (
boost::iostreams::zlib_decompressor() ) );
        char sourceArr[512];
        strm.push( boost::iostreams::array_source( sourceArr, sourceArr +
sizeof( sourceArr ) ) );
        strm.tellg();
}

The problem is that, at least on windows, and I assume other platforms
due to the somewhat lackluster interface of stream_buf, is implemented
in terms of pubseekoff( 0, ios_base::cur, ios_base::in ). This call
doesn't really alter the read head and should in this instance be
supported, but isn't.


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