
On 10/11/07 01:40, Roland Schwarz wrote:
I am searching for a library / component / pattern that will help me with the following problem:
I have a memory structure in raw memory (received from a measurement instrument), that is unaligned in its data members.
Now I want to have an access interface to this data that comes as close as possible to access of a struct. E.g.
struct foo { char a; int b; }
Altough my raw data "char* pdata" has an 8bit followed by a 32bit I want to be able to do something like:
foo data(pdata);
and then
char ch = data.a; int n = data.b;
Does anyone know about such a library? (This should work compiler/platform independent of course.)
There's something related described here: http://archives.free.net.ph/message/20070514.193240.ada2f1bb.en.html Unfortunately, its specific to Gregor's g++ variadic template compiler. OTOH, maybe the variadic version of the tuple and packed tuple described in the post could be converted back into a non-variadic version as in current fusion or mpl. Unfortunately that would involve adapting all the boost preprocessor logic in fusion or mpl's tuple to emulate Gregor's variadic templates for this particular case, but that's just the reverse of what was done to produce the mpl-vt.zip in <boost-vault>/variadic_templates. So, maybe it wouldn't be too much trouble.