Skip to content

Commit 78edc5a

Browse files
committed
[flexValue] some improvements
1 parent 20b39ff commit 78edc5a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Quick.Value.RTTI.pas

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Author : Kike Pérez
88
Version : 1.0
99
Created : 06/05/2019
10-
Modified : 09/04/2020
10+
Modified : 26/06/2020
1111
1212
This file is part of QuickLib: https://github.com/exilon/QuickLib
1313
@@ -69,6 +69,7 @@ TRTTIFlexValue = record helper for TFlexValue
6969
function AsType<T : class> : T;
7070
function AsRecord<T : record> : T;
7171
function AsArray<T> : TArray<T>;
72+
function AsInterfaceEx<T : IInterface> : T; overload;
7273
end;
7374

7475
implementation
@@ -81,6 +82,11 @@ function TRTTIFlexValue.AsArray<T>: TArray<T>;
8182
Result := (Self.Data as IValueTValue).Value.AsType<TArray<T>>;
8283
end;
8384

85+
function TRTTIFlexValue.AsInterfaceEx<T>: T;
86+
begin
87+
Result := T(Self.Data);
88+
end;
89+
8490
function TRTTIFlexValue.AsRecord<T>: T;
8591
begin
8692
if DataType <> dtRecord then raise Exception.Create('DataType not supported');

Quick.Value.pas

+1
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ function TFlexValue.CastToInterface: IInterface;
618618
dtNull : Result := nil;
619619
dtInterface : Result := fDataIntf;
620620
dtPointer : Result := IInterface(fDataIntf);
621+
dtVariant : Result := IInterface(fDataIntf);
621622
else raise Exception.Create('DataType not supported');
622623
end;
623624
except

0 commit comments

Comments
 (0)