M
me
Hi there.
I'm writing some code to interpret binary data.
The spec of the data is in the form of field names and field sizes.
The design is to take a byte array of data, and a struct representing
the fields, memcpy the first onto the second, then access the data:
e.g
struct DataType
{
Type1 DataA ;
Type2 DataB ;
Type7 DataC ;
};
Would represent data that has a field of 1 byte, then a field of 2
bytes, then a field of 7 bytes. I read 10 bytes, memcpy the data onto an
instance of DataType, then access the data through DataA,B,C etc...
This would be easy if the data was either 1,2,4,or 8 bytes, but its
not...some are 3, some are 7, some are 5
Is there a simple way of defining an integer type that is n bytes long?
cheers
I'm writing some code to interpret binary data.
The spec of the data is in the form of field names and field sizes.
The design is to take a byte array of data, and a struct representing
the fields, memcpy the first onto the second, then access the data:
e.g
struct DataType
{
Type1 DataA ;
Type2 DataB ;
Type7 DataC ;
};
Would represent data that has a field of 1 byte, then a field of 2
bytes, then a field of 7 bytes. I read 10 bytes, memcpy the data onto an
instance of DataType, then access the data through DataA,B,C etc...
This would be easy if the data was either 1,2,4,or 8 bytes, but its
not...some are 3, some are 7, some are 5
Is there a simple way of defining an integer type that is n bytes long?
cheers