Boost logo

Boost Users :

Subject: Re: [Boost-users] Seekg on a gzip'd file...Is this possible?
From: Gerrick Bivins (gbivins_at_[hidden])
Date: 2009-03-13 16:05:12

I changed my code a bit but I¹m still getting errors when trying to use
boost::iostreams::seek as follows:


What is the correct way to go about this?

On 3/13/09 9:29 AM, "Gerrick Bivins" <gbivins_at_[hidden]> wrote:

> Hello all,
> I¹m switching one of my projects over from java to c++. Basically it¹s a gzip
> file reader, where I¹d like to parse a bunch of numbers (floats, ints,
> doubles)
> and in some instances I¹d like to skip some of the data. I¹m a ³noob² to
> boost and after getting the file reader working using the boost like this:
> {
> ....
> std::ifstream ormodelFile(filenameForTimeStep.c_str(),
> std::ios_base::in|std::ios_base::binary);
> boost::iostreams::filtering_istreambuf compressedFileFilter;
> compressedFileFilter.push(boost::iostreams::gzip_decompressor());
> compressedFileFilter.push(ormodelFile);
> this->inputFile.rdbuf(&compressedFileFilter); //where inputFile is a an
> istream.
> ...
> //do the file reading
> }
> I tried to add the skipping parts to the code by simply calling:
> {
> ...
> double value;
> this->inputFile->seekg(sizeof(double),ios::cur);
> ...
> }
> the fail bit is set on the inputFile istream. Is it possible to do this using
> boost? I¹m pretty ³green² with boost so I¹m sure it¹s just my misunderstanding
> of how to use the lib but I couldn¹t find my way around the docs to well.
> The best I could find was that I need to somehow make my stream ³seekable² but
> it wasn¹t too clear to me how to do this.
> Any help would be greatly appreciated.
> Gerrick

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at