QUOTE (jdunham @ Apr 17 2009, 11:07 AM)
Thanks for the suggestions. Sounds like a clean way to do this so I'll give it a shot.
QUOTE (ShaunR @ Apr 17 2009, 12:21 PM)
Everyone will have their own methods and solutions to this one. It's an old problem with many equally correct solutions.
If you give an example stream and header structure we would probably be able to justify each approach better and you could pick the solution that best fits your preferences.
I find, generally, the best option, if possible, is to find the super set of the protocols and choose a display method that can cope with all of them.
Thanks for the reply. I hear where you're coming from. In my case, though, It's not just the contents of the fields that have changed but the number of fields. Specifically, the header is 62 bytes in both the original code and the new version. In the original version one of the fields was a 16 byte string used as an instrument ID string. I needed to add some extra timing information in this next revision so I added a U32 field to the header for the new info and shortened the instrument ID string from 16 bytes to 12 bytes (making the header longer had other implications). So now my Labview code needs to have 2 different types of clusters to handle both the old and new data. I was hoping I could just create 2 typedefs and instantiate the correct one but that's not possible.
There's probably an easy way to handle this specific case, but in the future this header could grow and have all sorts of new stuff in it. The suggested approach of just using a variant to hold the contents and a case statement to determine how the variant is interpreted seems like a good one. I've never worked with variants before but I guess this is exactly the type of situation they were created for, situations where the exact data type is not known at compile time.
dj