Show: Delphi C++
Display Preferences

System.TVarData

From XE3 API Documentation
Jump to: navigation, search

Delphi

  TVarData = packed record
    case Integer of
      0: (VType: TVarType;
          case Integer of
            0: (Reserved1: Word;
                case Integer of
                  0: (Reserved2, Reserved3: Word;
                      case Integer of
                        varSmallInt: (VSmallInt: SmallInt);
                        varInteger:  (VInteger: Integer);
                        varSingle:   (VSingle: Single);
                        varDouble:   (VDouble: Double);
                        varCurrency: (VCurrency: Currency);
                        varDate:     (VDate: TDateTime);
                        varOleStr:   (VOleStr: PWideChar);
                        varDispatch: (VDispatch: Pointer);
                        varError:    (VError: HRESULT);
                        varBoolean:  (VBoolean: WordBool);
                        varUnknown:  (VUnknown: Pointer);
                        varShortInt: (VShortInt: ShortInt);
                        varByte:     (VByte: Byte);
                        varWord:     (VWord: Word);
                        varLongWord: (VLongWord: LongWord);
                        varInt64:    (VInt64: Int64);
                        varUInt64:   (VUInt64: UInt64);
                        varString:   (VString: Pointer);
                        varAny:      (VAny: Pointer);
                        varArray:    (VArray: PVarArray);
                        varByRef:    (VPointer: Pointer);
                        varUString:  (VUString: Pointer);
                        varRecord:   (VRecord: TVarRecord);
                     );
                  1: (VLongs: array[0..{$IFDEF CPUX64}4{$ELSE}2{$ENDIF}] of LongInt);
               );
            2: (VWords: array [0..{$IFDEF CPUX64}10{$ELSE}6{$ENDIF}] of Word);
            3: (VBytes: array [0..{$IFDEF CPUX64}21{$ELSE}13{$ENDIF}] of Byte);
          );
      1: (RawData: array [0..{$IFDEF CPUX64}5{$ELSE}3{$ENDIF}] of LongInt);
  end;

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
    IDispatch*            VDispatch;    //  pdispVal
    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


Personal tools
Translations