Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2005-09-22 16:00:24

Support Requests item #1299123, was opened at 2005-09-22 15:00
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: jpstanley (jpstanley)
Assigned to: Nobody/Anonymous (nobody)
Summary: Boost.Iostreams and newline translation

Initial Comment:
I like the Boost.Iostreams framework in Boost 1.33.
But I haven't found a way to make it do exactly what I

I maintain software that parses files out of disk
images instead of the local file system. I'd like to
be able to wrap a C++ istream around my raw binary
read/seek APIs to make it easier to parse data from
disk images and interface with existing code.
Boost.Iostreams makes this job a piece of cake--except
that I haven't found a way to make the stream act like
an ifstream opened in text mode (I'm on Win32, btw).
In other words, I'd like to have CR, LF, and CRLF line
endings translated into \n when I read the data. There
is a newline_filter class provided which does nearly
exactly what I want--but it doesn't support seeking. I
still need seekg() and tellg() to work.

I tried writing my own filter, but I ran into some
problems. It seems the Boost stream buffer class is
built on the assumption that this will hold:

std::streamsize P0 = str.tellg();, 100);
std::streamsize P1 = str.tellg();
assert(P1 - P0 == 100);

But with an ifstream opened in text mode, this
assertion can fail (P1 - P0 > 100) if two-character
CRLF combinations were translated into a one-character
newline in the intervening data.

Is it possible to implement an input-seekable filter
that will let a Boost.Iostream behave this way?


You can respond by visiting:

SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP. Click here to play:
Boost-bugs mailing list

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