Flattened Variant Data Format

Updated Nov 5, 2020

Reported In

Software

  • LabVIEW
  • LabWindows/CVI

Issue Details

I would like to parse the variant datatype for my custom usage, but I cannot find any documentation on the flattened variant and its components.

Solution

The flattened variant datatype consist of the components:
  1. A u32 that represents the LabVIEW version number. This is used to interpret the data differently if there are data mutations.
  2. A type descriptor 
  3. The flattened data of the variant
  4. An i32 representing the number of attributes (0 means none)
  5. Repeat the following for a number of times equal to the integer read in step 4:
    1. string of name
    2. type descriptor of attribute data
    3. flattened data of the attribute

Additional Information

  • The integers are in big endian form
  • You have to use Flatten to string function to manipulate the variant and its contents
  • Be aware, that variant datatype can be modified within each LabVIEW version release depending on environment needs. To stay up to date with the variant components, take a moment to go through the release notes of the newest LabVIEW versions.