Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-03-11 16:06:52


on 3/11/00 2:59 PM, Greg Colvin at gcolvin_at_[hidden] wrote:

> To add my two cents worth, in 1988 and 1989 I wrote a database
> library that stored binary data on CD-ROM in big-endian format
> and loaded it on Intel, VAX, Sun, Apollo, and Macintosh machines.
> I used the same fetch-byte-and-shift trick that Darin describes
> with happy results. Ten years later no one has found cause to
> create platform-specific macros to improve performance.

And I made the identical argument to Beman a while back. He wasn't entirely
convinced, as I recall, but I'll let him speak for himself. I also hinted on
this list at an ingenious implementation by an ex-colleague of mine which
sounds a lot like what Darin's suggesting. Digging through my correspondence
with Beman, I find this (you can find my original commentary to the list in
the boost archives):

--------
>> You can
>> even make what looks like ordinary struct declarations which
>> describe the
>> layout of your data.
>
> You mean you can write structs like:
>
> struct {
> portable_int a;
> portable_int b;
> char c[20];
> } s;

yes, except that you (probably) don't want to see any raw data structures in
there. Hmm. Imagine what this might mean:

struct s : data_layout
{
    int24_data first3bytes;
    int32_data next4bytes;
    char_data c[20];
};

> Can you just read/write s, or do you have to somehow describe that s
> contains two portable_int's plus one char [20]?

Doesn't the declaration above do just that?

;)

----------

-Dave


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