Boost logo

Boost :

From: Jerry Schwarz (jerry_at_[hidden])
Date: 2007-05-31 02:00:07

For what its worth, I always envisioned alternative top level IO
classes using streambuf's as the underlying transport. The central
class of the iostream library is really streambuf and I've long
regretted not calling the library "streambuf". I always encourage
people to use streambuf's directly when all they want to do is
transport bytes.

So I like the idea of this library. It is more consistent with my
ideas of how "iostream" should be used than is using istream or
ostream directly to read and write binary files. But I would prefer
it if binary_istream, binary_ostream and binary_iostream had a
constructor that took a streambuf argument and that (at least
optionall) ownership would be transfered to the streambuf. That is
the stream would be responsible for freeing it.

This would work best if these classes were templatized on the
streambuf type so the if I had a binary_istream<filebuf> say rdbuf
would return a filebuf. (Templates were not available when iostream
was designed).

I realize that people like the connivence of classes like
binary_ifstream, but I don't think it's that much worse to write
something like

    binary_istream<filebuf> f( new filebuf(path));

or, if you prefer not to use the new expression directly supply
functions to build the filebuf.

        binary_istream<filebuf> f(mkFilebuf(path));

I note that as the code stands if I do

        binary_ifstream f(path);
        binary_istream& i = f;

then f.rdbuf() and i.rdbuf() will return different streambuf's. It
was to avoid that anomaly that the original (pre standard) iostream
did not have any way to change the streambuf of a stream after the
stream had been constructed.

On May 26, 2007, at 7:32 PM, Shams wrote:

> Hi,
> I have had a look at the example...
> Questions:
> 1. Apart from handling endianess what is really different from
> iostreams
> opened in binary mode?
> 2. Is/can the endianness BOM (byte order mark) written to the file
> automatically?
> Thanks
> Shams
> --
> "Ares Lagae" <ares.lagae_at_[hidden]> wrote in message
> news:f31613$i4g$
>> I have developed a small library for binary I/O, called
>> binary_iostreams,
>> and I am using it in several of my own projects. I was wondering
>> if there
>> is interest for such a binary_iostreams library?
>> The binary_iostreams is a small library, very similar to the
>> iostreams
>> library. Compared to iostreams, the unformatted I/O operators
>> remain, and
>> the formatted I/O operators now do binary I/O. This makes the
>> binary_iostreams library easy to use for anyone acquainted with the
>> iostreams library. The binary_iostreams library allows to set the
>> endianness of the output stream. Together with <cstdint>, this
>> allows for
>> portable binary I/O, although binary_iostreams does not claim to
>> be a full
>> blown serialization library.
>> Direct link to a motivating example:
>> The library:
>> binary_iostreams-0.1.tar.gz
>> The documentation:
>> Best regards,
>> --
>> Ares Lagae
>> Computer Graphics Research Group, Katholieke Universiteit Leuven
>> _______________________________________________
>> Unsubscribe & other changes:
> _______________________________________________
> Unsubscribe & other changes:
> listinfo.cgi/boost

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