BinStream -- binary streaming to a pack_t

BinStream is an adaptor class that allows streaming of POD (plain ordinary data) types to/from a pack_t type for efficiency reasons. POD types can be basic data types like ints/floats, structs of such, arrays of such and standard containers of such.

You can either use a BinStream class, which takes a pack_t reference (can be an xdr_pack object as well) in its constructor. Alternatively, you can construct the pack_t object directly with the BinStream using the template BinStreamT. The template argument refers to the pack_t type.


struct foo {a,b};
vector x(10,2);
pack_t p;
foo a; 
int i;
BinStream bs(p);
bs << 1 << a << x;
bs >> i >> a >> x;
BinStreamT<xdr_pack> bst("foo.dat","w");
bst << 1 << a << x;