Browse Source

+ provide IValueData's ExtractRawData(NoCopy)() in TValue (and also implement it for non-heap types)

git-svn-id: trunk@40693 -
svenbarth 6 years ago
parent
commit
17c3354f9c
1 changed files with 18 additions and 0 deletions
  1. 18 0
      packages/rtl-objpas/src/inc/rtti.pp

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

@@ -125,6 +125,8 @@ type
     function IsType(ATypeInfo: PTypeInfo): boolean; inline;
     function IsType(ATypeInfo: PTypeInfo): boolean; inline;
     function TryAsOrdinal(out AResult: int64): boolean;
     function TryAsOrdinal(out AResult: int64): boolean;
     function GetReferenceToRawData: Pointer;
     function GetReferenceToRawData: Pointer;
+    procedure ExtractRawData(ABuffer: Pointer);
+    procedure ExtractRawDataNoCopy(ABuffer: Pointer);
     class operator := (const AValue: String): TValue; inline;
     class operator := (const AValue: String): TValue; inline;
     class operator := (AValue: LongInt): TValue; inline;
     class operator := (AValue: LongInt): TValue; inline;
     class operator := (AValue: Single): TValue; inline;
     class operator := (AValue: Single): TValue; inline;
@@ -2303,6 +2305,22 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TValue.ExtractRawData(ABuffer: Pointer);
+begin
+  if Assigned(FData.FValueData) then
+    FData.FValueData.ExtractRawData(ABuffer)
+  else if Assigned(FData.FTypeInfo) then
+    Move((@FData.FAsPointer)^, ABuffer^, DataSize);
+end;
+
+procedure TValue.ExtractRawDataNoCopy(ABuffer: Pointer);
+begin
+  if Assigned(FData.FValueData) then
+    FData.FValueData.ExtractRawDataNoCopy(ABuffer)
+  else if Assigned(FData.FTypeInfo) then
+    Move((@FData.FAsPointer)^, ABuffer^, DataSize);
+end;
+
 class operator TValue.:=(const AValue: String): TValue;
 class operator TValue.:=(const AValue: String): TValue;
 begin
 begin
   Make(@AValue, System.TypeInfo(AValue), Result);
   Make(@AValue, System.TypeInfo(AValue), Result);