Boost logo

Boost Users :

From: Daryle Walker (darylew_at_[hidden])
Date: 2008-06-27 15:20:39


My class contains an array of bits, currently expressed as
boost::array<bool, 512>. Will archives compact representations to
multiple bits per serialized atom, or will they potentially waste a
lot of space?

Regardless of the answer, I was thinking of compacting the data
myself. One way would be to compact the array into
boost::array<unsigned char, CEIL(512 / CHAR_BIT)> and serialize
that. But I've wondered what happens between systems with differing
CHAR_BIT values. The solution I'm leaning towards is to create a
text string like base-64 (pack every 6 bits together) and serialize
that. By the way, a bit stream may not use all 512 bits and I'm also
tracking (and serializing) a length attribute. I guess I should make
sure that the length is serialized first. How do I serialize an
arbitrary text string? How do I write the serialization routines
knowing that one member (the bit array) is indirectly expressed (i.e.
translate to/from the text string)? I guess I need separate save &
load methods at least.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net