Class VariantFFM


public final class VariantFFM extends WindowsForeignFunctions
FFM representation of the Windows VARIANT structure used in COM/OLE automation.

VARIANT is a tagged union that can hold different types of data.

  • Field Details

  • Method Details

    • allocate

      public static MemorySegment allocate(Arena arena)
      Allocates and initializes an empty VARIANT.
      Parameters:
      arena - the arena for memory allocation
      Returns:
      a memory segment containing the initialized VARIANT
    • getVt

      public static int getVt(MemorySegment variant)
      Gets the variant type (vt field).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the variant type
    • getBstrVal

      public static String getBstrVal(MemorySegment variant, Arena arena)
      Gets the BSTR value from a VARIANT.
      Parameters:
      variant - the VARIANT memory segment
      arena - the arena for string conversion
      Returns:
      the string value, or empty string if null
    • getIntVal

      public static int getIntVal(MemorySegment variant)
      Gets the integer value from a VARIANT (VT_I4, VT_INT, VT_UI4, VT_UINT).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the integer value
    • getLongVal

      public static long getLongVal(MemorySegment variant)
      Gets the long value from a VARIANT (VT_I8, VT_UI8).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the long value
    • getShortVal

      public static short getShortVal(MemorySegment variant)
      Gets the short value from a VARIANT (VT_I2, VT_UI2, VT_BOOL).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the short value
    • getByteVal

      public static byte getByteVal(MemorySegment variant)
      Gets the byte value from a VARIANT (VT_I1, VT_UI1).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the byte value
    • getDoubleVal

      public static double getDoubleVal(MemorySegment variant)
      Gets the double value from a VARIANT (VT_R8).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the double value
    • getFloatVal

      public static float getFloatVal(MemorySegment variant)
      Gets the float value from a VARIANT (VT_R4).
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the float value
    • getBoolVal

      public static boolean getBoolVal(MemorySegment variant)
      Gets the boolean value from a VARIANT (VT_BOOL). In COM, VARIANT_TRUE is -1 and VARIANT_FALSE is 0.
      Parameters:
      variant - the VARIANT memory segment
      Returns:
      the boolean value
    • clear

      public static int clear(MemorySegment variant)
      Clears a VARIANT, releasing any resources.
      Parameters:
      variant - the VARIANT to clear
      Returns:
      HRESULT