Browse Source

+ add AsInt64 and AsUInt64

git-svn-id: trunk@36986 -
svenbarth 8 years ago
parent
commit
00757ec79f
1 changed files with 32 additions and 0 deletions
  1. 32 0
      packages/rtl-objpas/src/inc/rtti.pp

+ 32 - 0
packages/rtl-objpas/src/inc/rtti.pp

@@ -85,6 +85,8 @@ type
     function AsBoolean: boolean;
     function AsCurrency: Currency;
     function AsInteger: Integer;
+    function AsInt64: Int64;
+    function AsUInt64: QWord;
     function AsInterface: IInterface;
     function ToString: String;
     function GetArrayLength: SizeInt;
@@ -838,6 +840,36 @@ begin
     raise EInvalidCast.Create(SErrInvalidTypecast);
 end;
 
+function TValue.AsInt64: Int64;
+begin
+  if Kind in [tkInteger, tkInt64, tkQWord] then
+    case TypeData^.OrdType of
+      otSByte:  Result := FData.FAsSByte;
+      otUByte:  Result := FData.FAsUByte;
+      otSWord:  Result := FData.FAsSWord;
+      otUWord:  Result := FData.FAsUWord;
+      otSLong:  Result := FData.FAsSLong;
+      otULong:  Result := FData.FAsULong;
+      otSQWord: Result := FData.FAsSInt64;
+      otUQWord: Result := FData.FAsUInt64;
+    end;
+end;
+
+function TValue.AsUInt64: QWord;
+begin
+  if Kind in [tkInteger, tkInt64, tkQWord] then
+    case TypeData^.OrdType of
+      otSByte:  Result := FData.FAsSByte;
+      otUByte:  Result := FData.FAsUByte;
+      otSWord:  Result := FData.FAsSWord;
+      otUWord:  Result := FData.FAsUWord;
+      otSLong:  Result := FData.FAsSLong;
+      otULong:  Result := FData.FAsULong;
+      otSQWord: Result := FData.FAsSInt64;
+      otUQWord: Result := FData.FAsUInt64;
+    end;
+end;
+
 function TValue.AsInterface: IInterface;
 begin
   if Kind = tkInterface then