Boost logo

Boost :

Subject: Re: [boost] Interest in simple unformatted binary stream I/O?
From: Marsh Ray (marsh_at_[hidden])
Date: 2011-04-24 21:43:26


On 04/24/2011 07:12 AM, Beman Dawes wrote:
>
> int32_t x = 0x01020304;
> int32_t y = 0;
>
> f<< bin(x); // write 4 bytes
> f.seekg(0);
> f>> bin(y); // read 4 bytes

What about integral promotion? I.e. what if the platform int isn't 4 bytes?

What if you need to output 1 or 2 bytes?

> Is there interest in this for Boost?

Rather than a machine and compiler-dependent binary IO facility based on
iostreams, I'd rather have a simple, minimal, portable binary streaming
interface that handled endianness and alignment well for
wire-representation defined structures.

<iostream> brings in a huge header tree with 99% unnecessary
functionality for binary protocols. The more efficient the headers, the
better. Functions that didn't need to read could just include the header
for writing, and vice-versa.

- Marsh


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