System.TVarRec

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

TVarRec = record { do not pack this record; it is compiler-generated }

C++

struct TVarRec
{
  union
  {
    int          VInteger;
    bool         VBoolean;
    AnsiChar     VChar;
    long double* VExtended;
    PShortString VString;
    void*        VPointer;
    PAnsiChar    VPChar;
#if !defined(DELPHI_AUTOREFCOUNT)
    TObject*     VObject;
#else
    void*        VObject;
#endif
    TClass       VClass;
    WideChar     VWideChar;
    WideChar*    VPWideChar;
    void*        VAnsiString;
    Currency*    VCurrency;
    Variant*     VVariant;
    void*        VInterface;
    void*        VWideString;
    __int64*     VInt64;
    void*        VUnicodeString;
  };
  union
  {
    Byte VType;
  };
  __fastcall TVarRec(): VType(vtInteger), VInteger(0) {} //default int 0
  __fastcall TVarRec(int src): VType(vtInteger), VInteger(src) {}
  __fastcall TVarRec(unsigned src): VType(vtInteger), VInteger(src) {}
  __fastcall TVarRec(unsigned long src): VType(vtInteger), VInteger(src) {}
  __fastcall TVarRec(long src): VType(vtInteger), VInteger(src) {}
  __fastcall TVarRec(bool src): VType(vtBoolean), VBoolean(src) {}
  __fastcall TVarRec(char src): VType(vtChar), VChar(src) {}
#if defined(_WIN64)
  __fastcall TVarRec(const double& src): VType(vtExtended), VExtended(reinterpret_cast<Extended*>(const_cast<double*>(&src))) {}
#endif
  __fastcall TVarRec(const long double& src): VType(vtExtended), VExtended(const_cast<Extended*>(&src)) {}
  __fastcall TVarRec(const ShortString& src): VType(vtString), VString(const_cast<PShortString>(&src)) {}
  __fastcall TVarRec(const void* src): VType(vtPointer), VPointer(const_cast<Pointer>(src)) {}
#if !defined(_DELPHI_STRING_UNICODE)
  __fastcall TVarRec(const PChar src): VType(vtPChar), VPChar(src) {}
#endif
  __fastcall TVarRec(const char* src): VType(vtPChar), VPChar(reinterpret_cast<PAnsiChar>(const_cast<char*>(src))) {}
#if !defined(DELPHI_AUTOREFCOUNT)
  __fastcall TVarRec(const TObject& src): VType(vtObject), VObject(const_cast<TObject*>(&src)) {}
#endif
  __fastcall TVarRec(const TClass src): VType(vtClass), VClass(src) {}
  __fastcall TVarRec(const WideChar* src): VType(vtPWideChar), VPWideChar(const_cast<PWideChar>(src)) {}
  __fastcall TVarRec(WideChar src): VType(vtWideChar), VWideChar(src) {}
#if !defined(_DELPHI_NEXTGEN)
  __fastcall TVarRec(const AnsiString& src): VType(vtAnsiString), VAnsiString(const_cast<void*>(src.data())) {}
  __fastcall TVarRec(const RawByteString& src): VType(vtAnsiString), VAnsiString(const_cast<void*>(src.data())) {}
#endif
  __fastcall TVarRec(const Currency& src): VType(vtCurrency), VCurrency(const_cast<PCurrency>(&src)) {}
  __fastcall TVarRec(const Variant& src): VType(vtVariant), VVariant(const_cast<PVariant>(&src)) {}
#if !defined(_DELPHI_NEXTGEN)
  __fastcall TVarRec(const WideString& src): VType(vtWideString), VWideString(const_cast<WideString&>(src).data()) {}
#endif
  __fastcall TVarRec(const UnicodeString& src): VType(vtUnicodeString), VUnicodeString(const_cast<void*>(src.data())) {}
  __fastcall TVarRec(const __int64& src): VType(vtInt64), VInt64(const_cast<PInt64>(&src)) {}
  __fastcall TVarRec(const unsigned __int64& src): VType(vtInt64), VInt64(reinterpret_cast<PInt64>(const_cast<PUInt64>(&src))) {}
  TVarRec& __fastcall operator =(int src)
  {
    VType = vtInteger;
    VInteger = src;
    return *this;
  }
  TVarRec& __fastcall operator =(unsigned src)
  {
    VType = vtInteger;
    VInteger = src;
    return *this;
  }
  TVarRec& __fastcall operator =(long src)
  {
    VType = vtInteger;
    VInteger = src;
    return *this;
  }
  TVarRec& __fastcall operator =(unsigned long src)
  {
    VType = vtInteger;
    VInteger = src;
    return *this;
  }
  TVarRec& __fastcall operator =(const __int64& src)
  {
    VType = vtInt64;
    VInt64 = const_cast<PInt64>(&src);
    return *this;
  }
  TVarRec& __fastcall operator =(const unsigned __int64& src)
  {
    VType = vtInt64;
    VInt64 = reinterpret_cast<PInt64>(const_cast<PUInt64>(&src));
    return *this;
  }
  TVarRec& __fastcall operator =(bool src)
  {
    VType = vtBoolean;
    VBoolean = src;
    return *this;
  }
  TVarRec& __fastcall operator =(char src)
  {
    VType = vtChar;
    VChar = src;
    return *this;
  }
  TVarRec& __fastcall operator =(const long double& src)
  {
    VType = vtExtended;
    VExtended = const_cast<PExtended>(&src);
    return *this;
  }
  TVarRec& __fastcall operator =(const ShortString& src)
  {
    VType = vtString;
    VString = const_cast<PShortString>(&src);
    return *this;
  }
  TVarRec& __fastcall operator =(const void* src)
  {
    VType = vtPointer;
    VPointer = const_cast<Pointer>(src);
    return *this;
  }
#if !defined(_DELPHI_STRING_UNICODE)
  TVarRec& __fastcall operator =(const PChar src)
  {
    VType = vtPChar;
    VPChar = src;
    return *this;
  }
#endif
  TVarRec& __fastcall operator =(const char* src)
  {
    VType = vtPChar;
    VPChar = static_cast<PAnsiChar>(const_cast<char*>(src));
    return *this;
  }
#if !defined(DELPHI_AUTOREFCOUNT)
  TVarRec& __fastcall operator =(const TObject& src)
  {
    VType = vtObject;
    VObject = const_cast<TObject*>(&src);
    return *this;
  }
#endif
  TVarRec& __fastcall operator =(const TClass& src)
  {
    VType = vtClass;
    VClass = src;
    return *this;
  }
  TVarRec& __fastcall operator =(WideChar src)
  {
    VType = vtWideChar;
    VWideChar = src;
    return *this;
  }
  TVarRec& __fastcall operator =(const WideChar* src)
  {
    VType = vtPWideChar;
    VPWideChar = const_cast<PWideChar>(src);
    return *this;
  }
#if !defined(_DELPHI_NEXTGEN)
  TVarRec& __fastcall operator =(const AnsiString& src)
  {
    VType = vtAnsiString;
    VAnsiString = const_cast<void*>(src.data());
    return *this;
  }
  TVarRec& __fastcall operator =(const WideString& src)
  {
    VType = vtWideString;
    VWideString = const_cast<WideString&>(src).data();
    return *this;
  }
#endif
  TVarRec& __fastcall operator =(const UnicodeString& src)
  {
    VType = vtUnicodeString;
    VUnicodeString = const_cast<void*>(src.data());
    return *this;
  }
  TVarRec& __fastcall operator =(const Currency& src)
  {
    VType = vtCurrency;
    VCurrency = const_cast<PCurrency>(&src);
    return *this;
  }
  TVarRec& __fastcall operator =(const Variant& src)
  {
    VType = vtVariant;
    VVariant = const_cast<PVariant>(&src);
    return *this;
  }
};

プロパティ

種類 可視性 ソース ユニット
record
struct
public
System.pas
systvar.h
System System

説明

TVarRec は、型なしの配列パラメータを持つ関数の内部で使用されます。

TVarRec 型は、Delphi の const の配列のパラメータ型を持つ関数の内部で使用されます。Delphi では、コンパイラが、この配列内の各要素を自動的に TVarRec 型の値に変換します。C++ では、この関数パラメータは、TVarRec 型の値の配列として表現されます。

const パラメータの配列を持つ関数を実装する際に、その配列の個々の要素を扱うには、TVarRec を使用します。

VType フィールドは、各 TVarRec 値の単純な型を表します。TVarRec 構造体のこのタグで渡される値は、さまざまな定数で表現されます。これらの定数は System ユニットで定義されています。以下にその一覧を示します。

Delphi の定数:



vtInteger

= 0;

vtBoolean

= 1;

vtCharacter

= 2;

vtExtended

= 3;

vtString

= 4;

vtPointer

= 5;

vtPChar

= 6;

vtObject

= 7;

vtClass

= 8;

vtWideChar

= 9;

vtPWideChar

= 10;

vtAnsiString

= 11;

vtCurrency

= 12;

vtVariant

= 13;

vtInterface

= 14;

vtWideString

= 15;

vtInt64

= 16;



C ++ の定数:



static const Shortint vtInteger

= 0x0;

static const Shortint vtBoolean

= 0x1;

static const Shortint vtCharacter

= 0x2;

static const Shortint vtExtended

= 0x3;

static const Shortint vtString

= 0x4;

static const Shortint vtPointer

= 0x5;

static const Shortint vtPChar

= 0x6;

static const Shortint vtObject

= 0x7;

static const Shortint vtClass

= 0x8;

static const Shortint vtWideChar

= 0x9;

static const Shortint vtPWideChar

= 0xa;

static const Shortint vtAnsiString

= 0xb;

static const Shortint vtCurrency

= 0xc;

static const Shortint vtVariant

= 0xd;

static const Shortint vtInterface

= 0xe;

static const Shortint vtWideString

= 0xf;

static const Shortint vtInt64

= 0x10;



メモ:  C++ では、sysopen.h で定義されている ARRAYOFCONST マクロを使用して、TVarRec 型の値の配列を作成できます。