|
Boost : |
Subject: Re: [boost] Interest in simple unformatted binary stream I/O?
From: Beman Dawes (bdawes_at_[hidden])
Date: 2011-05-27 07:41:19
On Fri, Apr 29, 2011 at 1:14 AM, Marsh Ray <marsh_at_[hidden]> wrote:
> On 04/28/2011 10:15 PM, Scott McMurray wrote:
>>
>> On Sun, Apr 24, 2011 at 18:43, Marsh Ray<marsh_at_[hidden]> wrote:
>>>
>>> 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.
>>>
>>
>> Would you be fine with it working on streambufs? That way you'd only
>> need<streambuf>...
>
> The last time I messed with streambufs (some years ago) I came to the
> conclusion that they could not be accessed multithreadedly in a natural way.
> I tried to define my own custom ostream channel and it took hundreds of
> lines of code to get something that just functional and not optimized. IIRC,
> streamsize was defined to be a signed int and not 64-bit clean.
>
<snip>
Perhaps you are looking for something like the following?
http://github.com/Beman/Boost-Btree/blob/master/boost/btree/detail/binary_file.hpp
It is implemented in terms of posix open/close/read/write, so is about
as close to the metal as you can get. It needs more work before it is
ready for general use.
I've used something similar for many years, but never had time to get
it ready for Boost.
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk