I'm trying to parse returned information that can have a variable amount of data in a structure. I'm not sure how to do this efficiently, I wrote a class that contains each variable as a function and that function returns the data by calculating the appropriate offset however its not very manageable, there must be a better way. I've read about vectors (not much experience with them) but when I add them to a structure it adds additional padding which shifts all the variables over.
for example:
struct info_t {
UINT32 signature;
UINT32 elements[NUM_ELEMENTS];
UINT32 options;
};
NUM_ELEMENTS is dynamically generated, and only known at runtime, the elements variable must be exactly NUM_ELEMENTS in size or the options variable will have the wrong offset.
I'm happy if I can initialize the structure pointer when its needed, but C++ won't let me get past having an unknown NUM_ELEMENTS variable during compile. Any ideas? Thanks.
elements?