|
Boost : |
From: Michael D. Crawford (crawford_at_[hidden])
Date: 2000-11-18 16:24:25
> This code will fail silently (because int is only 16-bits on some systems -
> i should have been long or int_least32_t )
I think this might be the reason Andy took operator<< and operator>>
_out_ of ZStream for the release (I haven't asked). Instead you have to
explicitly say the size you want to write, so you can do something like:
char myChar = 1;
stream.WriteInt32( myChar ); // writes 0x00000001
because the applications built with ZooLib so far are usually wanting to
use streams for binary file formats and network stream and packet
formats where it is critical to write a certain number of bytes, Andy
makes it explicit.
I can understand the need to switch byte orders to handle particular
formats. If you have the luxury of designing your own format from
scratch, I'd like to suggest it's worth your while almost always to make
it big-endian regardless of the target machine, but sometimes you do
need the very highest performance and sometimes you don't have the
luxury of making a choice.
Mike
-- Michael D. Crawford GoingWare Inc. - Expert Software Development and Consulting http://www.goingware.com crawford_at_[hidden] Tilting at Windmills for a Better Tomorrow.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk