On Wed, 1 Sep 2004, Georgios Diamantopoulos wrote:
Hi Mike,
I think we could all use that class, especially if it comes with boost.
Let us know what happens and thanks :)
George
Hmm, since this subject is coming up here and has also just popped up on comp.lang.c++.moderated, I'll venture an offering.
A little over a year ago, I wrote a general-purpose binary packing/unpacking class (inspired by Perl and Python's pack() and unpack()) that has held up pretty well in production for over a year now. I've always wanted to ask my company for permission to release it into the public domain (maybe even into Boost?!?), but haven't pushed it as I'd not heard anyone looking for anything quite like it--until now.
If anyone's interested, I'll pursue getting permission from my company to open it up ASAP.
To solve the endianness, size, and padding problems, the approach I'd take with my class would be to make sure the protocol expected a single character indicating the byte order of the data stream first; then you'd grab the appropriate unpacker from the factory and start unpacking away. It's up to the protocol writer to know how to unpack the bytes in the proper order into the proper structures from there.
Of course, packing/unpacking isn't quite the same as serialization, I'm sure, but maybe serialization isn't exactly the term that applies here?
CORBA (omg.org) uses CDR (Common Data Representation) in its transport protocol. In the (free) ACE framework (http://www.cs.wustl.edu/~schmidt/ACE.html) it is generally used for sending binary data over the wire. Since CDR is a standard and there are many implementations of it it might be an alternative. Volker -- Volker Börchers TECON Systems AG, http://www.tecon.de