System.TVarData

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TVarData = packed record

C++

struct TVarData
{
  union
  {
    uint16_t    VType;    // Delphi-compatible - Variant Type member
#if defined(VARIANT_NATIVE_SUPPORT)
    VARTYPE     vt;       // tagVARIANT compatible member
#else
    uint16_t    vt;       // Expose a generic 'vt' member
#endif
  };
  uint16_t Reserved1;
  uint16_t Reserved2;
  uint16_t Reserved3;
  union
  {
    System::Smallint      VSmallint;    //  iVal
    System::Integer       VInteger;     //  lVal
    System::Single        VSingle;      //  fltVal
    System::Double        VDouble;      //  dblVal
    System::CurrencyBase  VCurrency;    //  cyVal
    System::TDateTimeBase VDate;        //  date
    System::PWideChar     VOleStr;      //  bstrVal
#ifdef _WIN32
    IDispatch*            VDispatch;    //  pdispVal
#else
    System::IDispatch*    VDispatch;    //  pdispVal
#endif
    System::HResult       VError;       //  scode
    System::WordBool      VBoolean;     //  boolVal
    IUnknown*             VUnknown;     //  punkVal
    System::Byte          VByte;        //  bVal
    System::Int8          VShortint;    //  charVal
    System::Int8          VShortInt;    //  charVal
    System::Pointer       VString;      //  ??????
    System::PVarArray     VArray;       //  parray
    System::Pointer       VPointer;     //  byref
    __int64               VInt64;       //  llVal
    unsigned __int64      VUInt64;      //  ullVal
    System::Word          VWord;        //  uiVal
    System::LongWord      VLongWord;    //  ulVal
    System::TVarRecord    VRecord;      //  struct __tagBRECORD
#if defined(VARIANT_NATIVE_SUPPORT)
    LONG          lVal;
    BYTE          bVal;
    SHORT         iVal;
    FLOAT         fltVal;
    DOUBLE        dblVal;
    VARIANT_BOOL  boolVal;
    SCODE         scode;
    CY            cyVal;
    DATE          date;
    BSTR          bstrVal;
    LONG64        llVal;
    ULONG64       ullVal;
    IUnknown     *punkVal;
    IDispatch    *pdispVal;
    SAFEARRAY    *parray;
    BYTE         *pbVal;
    SHORT        *piVal;
    LONG         *plVal;
    FLOAT        *pfltVal;
    DOUBLE       *pdblVal;
    VARIANT_BOOL *pboolVal;
    SCODE        *pscode;
    CY           *pcyVal;
    DATE         *pdate;
    BSTR         *pbstrVal;
    IUnknown    **ppunkVal;
    IDispatch   **ppdispVal;
    SAFEARRAY   **pparray;
    VARIANT      *pvarVal;
    PVOID         byref;
    CHAR          cVal;
    USHORT        uiVal;
    ULONG         ulVal;
    INT           intVal;
    UINT          uintVal;
    DECIMAL      *pdecVal;
    CHAR         *pcVal;
    USHORT       *puiVal;
    ULONG        *pulVal;
    INT          *pintVal;
    UINT         *puintVal;
    LONG64       *pllVal;
    ULONG64      *pullVal;
#endif
  };
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.pas
systvar.h
System System

Description

TVarData represents Variant information.

TVarData is the base class for Variant.

Note: The internal structure of a Variant as designated by TVarData is identical to the Variant type used by OLE and the Win32 APIs.

struct TVarData
{
  union
  {
    Word     VType;    // Delphi-compatible - Variant Type member
    VARTYPE  vt;       // tagVARIANT compatible member
  };
  Word Reserved1;
  Word Reserved2;
  Word Reserved3;
  union
  {
    // Delphi-compatible Variant members
    Smallint      VSmallint;    //  iVal
    Integer       VInteger;     //  lVal
    Single        VSingle;      //  fltVal
    Double        VDouble;      //  dblVal
    CurrencyBase  VCurrency;    //  cyVal
    TDateTimeBase VDate;        //  date
    PWideChar     VOleStr;      //  bstrVal
    IDispatch*    VDispatch;    //  pdispVal
    HResult       VError;       //  scode
    WordBool      VBoolean;     //  boolVal
    IUnknown*     VUnknown;     //  punkVal
    Byte          VByte;        //  bVal
    Pointer       VString;      //  ??????
    PVarArray     VArray;       //  parray
    Pointer       VPointer;     //  byref
    // tagVARIANT compatible members (from OAIDL.H)
    // Allowing all types marked as [V] (may appear in a VARIANT to be initialized)
    LONG          lVal;
    BYTE          bVal;
    SHORT         iVal;
    FLOAT         fltVal;
    DOUBLE        dblVal;
    VARIANT_BOOL  boolVal;
    SCODE         scode;
    CY            cyVal;
    DATE          date;
    BSTR          bstrVal;
    IUnknown     *punkVal;
    IDispatch    *pdispVal;
    SAFEARRAY    *parray;
    BYTE         *pbVal;
    SHORT        *piVal;
    LONG         *plVal;
    FLOAT        *pfltVal;
    DOUBLE       *pdblVal;
    VARIANT_BOOL *pboolVal;
    SCODE        *pscode;
    CY           *pcyVal;
    DATE         *pdate;
    BSTR         *pbstrVal;
    IUnknown    **ppunkVal;
    IDispatch   **ppdispVal;
    SAFEARRAY   **pparray;
    VARIANT      *pvarVal;
    PVOID         byref;
    CHAR          cVal;
    USHORT        uiVal;
    ULONG         ulVal;
    INT           intVal;
    UINT          uintVal;
    DECIMAL      *pdecVal;
    CHAR         *pcVal;
    USHORT       *puiVal;
    ULONG        *pulVal;
    INT          *pintVal;
    UINT         *puintVal;
  };
};

The VType of TVarData contains the type code of the variant in the lower twelve bits (the bits defined by varTypeMask).

The following values are used for VType:

#define varEmpty (Byte)(0)
#define varNull (ByteByte_Type)(1)
#define varSmallint (ByteByte_Type)(2)
#define varInteger (ByteByte_Type)(3)
#define varSingle (ByteByte_Type)(4)
#define varDouble (ByteByte_Type)(5)
#define varCurrency (ByteByte_Type)(6)
#define varDate (ByteByte_Type)(7)
#define varOleStr (ByteByte_Type)(8)
#define varDispatch (ByteByte_Type)(9)
#define varError (ByteByte_Type)(10)
#define varBoolean (ByteByte_Type)(11)
#define varVariant (ByteByte_Type)(12)
#define varUnknown (ByteByte_Type)(13)
#define varByte (ByteByte_Type)(17)
#define varString (WordWord_Type)(256)
#define varTypeMask (WordWord_Type)(4095)
#define varArray (WordWord_Type)(8192)
#define varByRef (WordWord_Type)(16384)
#define varStrArg (ByteByte_Type)(72)
#define vtInteger (ByteByte_Type)(0)
#define vtBoolean (ByteByte_Type)(1)
#define vtChar (ByteByte_Type)(2)
#define vtExtended (ByteByte_Type)(3)
#define vtString (ByteByte_Type)(4)
#define vtPointer (ByteByte_Type)(5)
#define vtPChar (ByteByte_Type)(6)
#define vtObject (ByteByte_Type)(7)
#define vtClass (ByteByte_Type)(8)
#define vtWideChar (ByteByte_Type)(9)
#define vtPWideChar (ByteByte_Type)(10)
#define vtAnsiString (ByteByte_Type)(11)
#define vtCurrency (ByteByte_Type)(12)
#define vtVariant (ByteByte_Type)(13)

In addition, the varArray bit may be set to indicate that the variant is an array, and the varByRef bit may be set to indicate that the variant contains a reference as opposed to a value.

Word Reserved1;
Word Reserved2;
Word Reserved3;

The Reserved1, Reserved2, and Reserved3 members of TVarData are unused.

union
{
  Smallint VSmallint;
  Integer VInteger;
  Single VSingle;
  Double VDouble;
  CurrencyBase VCurrency;
  TDateTimeBase VDate;
  PWideChar VOleStr;
  Ole2::IDispatch* VDispatch;
  Integer VError;
  WordBool VBoolean;
  Ole2::IUnknown* VUnknown;
  Byte VByte;
  Pointer VString;
  PVarArray VArray;
  Pointer VPointer;
};

The contents of the remaining 8 bytes of TVarData depend on the VType field. If neither the varArray nor the varByRef bits are set, the variant contains a value of the given type.

If the varArray bit is set, the variant contains a pointer to a TVarArray structure that defines the specifics of the array. The type of each array element is given by the varTypeMask bits in VType.

If the varByRef bit is set, the variant contains a reference to a value of the type given by the varTypeMask and varArray bits in VType.

Code Examples