Răsfoiți Sursa

[flexValue] some improvements

Exilon 5 ani în urmă
părinte
comite
78edc5aeb0
2 a modificat fișierele cu 8 adăugiri și 1 ștergeri
  1. 7 1
      Quick.Value.RTTI.pas
  2. 1 0
      Quick.Value.pas

+ 7 - 1
Quick.Value.RTTI.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 06/05/2019
   Created     : 06/05/2019
-  Modified    : 09/04/2020
+  Modified    : 26/06/2020
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -69,6 +69,7 @@ type
     function AsType<T : class> : T;
     function AsType<T : class> : T;
     function AsRecord<T : record> : T;
     function AsRecord<T : record> : T;
     function AsArray<T> : TArray<T>;
     function AsArray<T> : TArray<T>;
+    function AsInterfaceEx<T : IInterface> : T; overload;
   end;
   end;
 
 
 implementation
 implementation
@@ -81,6 +82,11 @@ begin
   Result := (Self.Data as IValueTValue).Value.AsType<TArray<T>>;
   Result := (Self.Data as IValueTValue).Value.AsType<TArray<T>>;
 end;
 end;
 
 
+function TRTTIFlexValue.AsInterfaceEx<T>: T;
+begin
+  Result := T(Self.Data);
+end;
+
 function TRTTIFlexValue.AsRecord<T>: T;
 function TRTTIFlexValue.AsRecord<T>: T;
 begin
 begin
   if DataType <> dtRecord then raise Exception.Create('DataType not supported');
   if DataType <> dtRecord then raise Exception.Create('DataType not supported');

+ 1 - 0
Quick.Value.pas

@@ -618,6 +618,7 @@ begin
       dtNull : Result := nil;
       dtNull : Result := nil;
       dtInterface : Result := fDataIntf;
       dtInterface : Result := fDataIntf;
       dtPointer : Result := IInterface(fDataIntf);
       dtPointer : Result := IInterface(fDataIntf);
+      dtVariant : Result := IInterface(fDataIntf);
       else raise Exception.Create('DataType not supported');
       else raise Exception.Create('DataType not supported');
     end;
     end;
   except
   except