System.Rtti.TValue

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TValue = record
  private
    function GetIsEmpty: Boolean;
    function GetTypeInfo: PTypeInfo;
    function GetTypeKind: TTypeKind;
    function GetTypeDataProp: PTypeData;
    function GetDataSize: Integer;
    constructor Create(ATypeInfo: PTypeInfo);
    class function GetEmpty: TValue; static;
    procedure Get<T>(out Result: T);
  public
    class operator Implicit(const Value: string): TValue;
    class operator Implicit(Value: Integer): TValue;
    class operator Implicit(Value: Cardinal): TValue;
    class operator Implicit(Value: Single): TValue;
    class operator Implicit(Value: Double): TValue;
    class operator Implicit(Value: Extended): TValue;
    class operator Implicit(Value: Currency): TValue;
    class operator Implicit(Value: Int64): TValue;
    class operator Implicit(Value: UInt64): TValue;
    class operator Implicit(Value: TObject): TValue;
    class operator Implicit(Value: TClass): TValue;
    class operator Implicit(Value: Boolean): TValue;
    class operator Implicit(const VarRec: TVarRec): TValue; inline;
    class function FromVariant(const Value: Variant): TValue; static;
    class function From<T>(const Value: T): TValue; static;
    class function FromOrdinal(ATypeInfo: PTypeInfo; AValue: Int64): TValue; static;
    class function FromArray(ArrayTypeInfo: PTypeInfo; const Values: array of TValue): TValue; static;
    class function FromVarRec(const VarRec: TVarRec): TValue; static;
    property Kind: TTypeKind read GetTypeKind;
    property TypeInfo: PTypeInfo read GetTypeInfo;
    property TypeData: PTypeData read GetTypeDataProp;
    property IsEmpty: Boolean read GetIsEmpty;
    function IsObject: Boolean;
    function IsObjectInstance: Boolean;
    function AsObject: TObject;
    function IsInstanceOf(AClass: TClass): Boolean;
    function IsClass: Boolean;
    function AsClass: TClass;
    function IsOrdinal: Boolean;
    function AsOrdinal: Int64;
    function TryAsOrdinal(out AResult: Int64): Boolean;
    function IsType<T>(const EmptyAsAnyType: Boolean = True): Boolean; overload;
    function IsType(ATypeInfo: PTypeInfo; const EmptyAsAnyType: Boolean = True): Boolean; overload;
    function AsType<T>(const EmptyAsAnyType: Boolean = True): T;
    function TryAsType<T>(out AResult: T; const EmptyAsAnyType: Boolean = True): Boolean;
    function Cast<T>(const EmptyAsAnyType: Boolean = True): TValue; overload;
    function Cast(ATypeInfo: PTypeInfo;  const EmptyAsAnyType: Boolean = True): TValue; overload;
    function TryCast(ATypeInfo: PTypeInfo; out AResult: TValue; const EmptyAsAnyType: Boolean = True): Boolean;
    function AsInteger: Integer;
    function AsBoolean: Boolean;
    function AsExtended: Extended;
    function AsInt64: Int64;
    function AsUInt64: UInt64;
    function AsInterface: IInterface;
    function AsString: string;
    function AsVariant: Variant;
    function AsCurrency: Currency;
    function IsArray: Boolean;
    function AsVarRec: TVarRec;
    function GetArrayLength: Integer;
    function GetArrayElement(Index: Integer): TValue;
    procedure SetArrayElement(Index: Integer; const AValue: TValue);
    class procedure Make(ABuffer: Pointer; ATypeInfo: PTypeInfo; out Result: TValue); overload; static;
    class procedure Make(AValue: NativeInt; ATypeInfo: PTypeInfo; out Result: TValue); overload; static;
    class procedure MakeWithoutCopy(ABuffer: Pointer; ATypeInfo: PTypeInfo; out Result: TValue; IsMoved: Boolean = False); overload; static;
    property DataSize: Integer read GetDataSize;
    procedure ExtractRawData(ABuffer: Pointer);
    procedure ExtractRawDataNoCopy(ABuffer: Pointer);
    function GetReferenceToRawData: Pointer;
    function GetReferenceToRawArrayElement(Index: Integer): Pointer;
    class property Empty: TValue read GetEmpty;
    function ToString: string;
  private
    FData: TValueData;
  end;

C++

struct __declspec(delphirecord) TValue
{
private:
    bool __fastcall GetIsEmpty();
    System::Typinfo::PTypeInfo __fastcall GetTypeInfo();
    System::TTypeKind __fastcall GetTypeKind();
    System::Typinfo::PTypeData __fastcall GetTypeDataProp();
    int __fastcall GetDataSize();
protected:
    __fastcall TValue(System::Typinfo::PTypeInfo ATypeInfo);
private:
    static TValue __fastcall GetEmpty();
    template<typename T> void __fastcall Get(/* out */ T &Result);
public:
    static TValue __fastcall _op_Implicit(const System::UnicodeString Value);
    TValue& __fastcall operator=(const System::UnicodeString Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(int Value);
    TValue& __fastcall operator=(int Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(unsigned Value);
    TValue& __fastcall operator=(unsigned Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(float Value);
    TValue& __fastcall operator=(float Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(double Value);
    TValue& __fastcall operator=(double Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(System::Extended Value);
    TValue& __fastcall operator=(System::Extended Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(System::Currency Value);
    TValue& __fastcall operator=(System::Currency Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(__int64 Value);
    TValue& __fastcall operator=(__int64 Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(unsigned __int64 Value);
    TValue& __fastcall operator=(unsigned __int64 Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(System::TObject* Value);
    TValue& __fastcall operator=(System::TObject* Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(System::TClass Value);
    TValue& __fastcall operator=(System::TClass Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(bool Value);
    TValue& __fastcall operator=(bool Value) { *this = TValue::_op_Implicit(Value); return *this; };
    static TValue __fastcall _op_Implicit(const System::TVarRec &VarRec);
    TValue& __fastcall operator=(const System::TVarRec &VarRec) { *this = TValue::_op_Implicit(VarRec); return *this; };
    static TValue __fastcall FromVariant(const System::Variant &Value);
    template<typename T> static TValue __fastcall From(const T Value);
    static TValue __fastcall FromOrdinal(System::Typinfo::PTypeInfo ATypeInfo, __int64 AValue);
    static TValue __fastcall FromArray(System::Typinfo::PTypeInfo ArrayTypeInfo, const TValue *Values, const int Values_High);
    static TValue __fastcall FromVarRec(const System::TVarRec &VarRec);
    __property System::TTypeKind Kind = {read=GetTypeKind};
    __property System::Typinfo::PTypeInfo TypeInfo = {read=GetTypeInfo};
    __property System::Typinfo::PTypeData TypeData = {read=GetTypeDataProp};
    __property bool IsEmpty = {read=GetIsEmpty};
    bool __fastcall IsObject();
    bool __fastcall IsObjectInstance();
    System::TObject* __fastcall AsObject();
    bool __fastcall IsInstanceOf(System::TClass AClass);
    bool __fastcall IsClass();
    System::TClass __fastcall AsClass();
    bool __fastcall IsOrdinal();
    __int64 __fastcall AsOrdinal();
    bool __fastcall TryAsOrdinal(/* out */ __int64 &AResult);
    template<typename T> bool __fastcall IsType(const bool EmptyAsAnyType = true)/* overload */;
    bool __fastcall IsType(System::Typinfo::PTypeInfo ATypeInfo, const bool EmptyAsAnyType = true)/* overload */;
    template<typename T> T __fastcall AsType(const bool EmptyAsAnyType = true);
    template<typename T> bool __fastcall TryAsType(/* out */ T &AResult, const bool EmptyAsAnyType = true);
    template<typename T> TValue __fastcall Cast(const bool EmptyAsAnyType = true)/* overload */;
    TValue __fastcall Cast(System::Typinfo::PTypeInfo ATypeInfo, const bool EmptyAsAnyType = true)/* overload */;
    bool __fastcall TryCast(System::Typinfo::PTypeInfo ATypeInfo, /* out */ TValue &AResult, const bool EmptyAsAnyType = true);
    int __fastcall AsInteger();
    bool __fastcall AsBoolean();
    System::Extended __fastcall AsExtended();
    __int64 __fastcall AsInt64();
    unsigned __int64 __fastcall AsUInt64();
    System::_di_IInterface __fastcall AsInterface();
    System::UnicodeString __fastcall AsString();
    System::Variant __fastcall AsVariant();
    System::Currency __fastcall AsCurrency();
    bool __fastcall IsArray();
    System::TVarRec __fastcall AsVarRec();
    int __fastcall GetArrayLength();
    TValue __fastcall GetArrayElement(int Index);
    void __fastcall SetArrayElement(int Index, const TValue &AValue);
    static void __fastcall Make(void * ABuffer, System::Typinfo::PTypeInfo ATypeInfo, /* out */ TValue &Result)/* overload */;
    static void __fastcall Make(NativeInt AValue, System::Typinfo::PTypeInfo ATypeInfo, /* out */ TValue &Result)/* overload */;
    static void __fastcall MakeWithoutCopy(void * ABuffer, System::Typinfo::PTypeInfo ATypeInfo, /* out */ TValue &Result, bool IsMoved = false)/* overload */;
    __property int DataSize = {read=GetDataSize};
    void __fastcall ExtractRawData(void * ABuffer);
    void __fastcall ExtractRawDataNoCopy(void * ABuffer);
    void * __fastcall GetReferenceToRawData();
    void * __fastcall GetReferenceToRawArrayElement(int Index);
    /* static */ __property TValue Empty = {read=GetEmpty};
    System::UnicodeString __fastcall ToString();
private:
    TValueData FData;
public:
    TValue() {}
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.Rtti.pas
System.Rtti.hpp
System.Rtti System.Rtti

Description

Represents a lightweight version of the Variant type.

TValue is a data structure that can store different kinds of data types. TValue is used in the Rtti unit to ease the access to fields and method parameters.

See Also