Boost logo

Boost :

Subject: Re: [boost] Any interest in bitstream class?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2013-06-30 04:08:51


> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Paul Long
> Sent: Saturday, June 29, 2013 12:19 AM
> To: boost_at_[hidden]
> Subject: Re: [boost] Any interest in bitstream class?
>
> On 6/28/2013 3:32 PM, Mathias Gaunard wrote:
> > - how do you overload operator>> or operator<< for your stream?
> I'm not sure what you mean by "how." To date, I have only implemented the input side and so
haven't
> overloaded operator<<. For operator>>, I have overloaded it for various right-hand parameters,
> including integrals and a few stream manipulators, such as aligng(). The left hand is always an
ibitstream
> reference (which will be extended to bitstream and obitstream references once I support output
> streams).
> > How do you avoid conflicts with text-based overloads?
> Maybe I misunderstand your question, but I'm not even aware of how there can be a conflict. Since
> these operators are overloaded with left hand of bitstream, ibitstream, or obitstream, they cannot
be
> applied to the std::iostream derivatives. Is that what you mean?
> > - what does writing an int to a stream actually do? Is it the same
> > behaviour as write(&i, sizeof(int)), or does it translate the int to
> > big-endian first?
> Effectively the latter. It does not assume any particular endianness of the platform (for example,
it does
> not blindly copy platform memory to the bit stream) and therefore does not actually "translate"
between
> endians. The effect, however, is that integrals in the bit stream are always big endian and
integrals on
> the platform are always their native endian. That said, awareness of platform endianness could
inform
> future optimizations.

Don't forget that a Boost.Endian library exists and has been accepted - even if the final
implementation has been delayed by Beman being busy with C++11 standards work.

Docs are here

http://boost.cowic.de/rc/endian/doc/

I have no idea if this is relevant to the bitstream library and endian streams.

Paul

---
Paul A. Bristow,
Prizet Farmhouse, Kendal LA8 8AB  UK
+44 1539 561830  07714330204
pbristow_at_[hidden]

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