浏览代码

+ add = and <> operators to TValue based on the existing SameValue()

Sven/Sarah Barth 1 天之前
父节点
当前提交
20022beca8
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      packages/rtl-objpas/src/inc/rtti.pp

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

@@ -286,6 +286,8 @@ type
     class operator := (AValue: TDateTime): TValue; inline;
     class operator := (AValue: TDate): TValue; inline;
     class operator := (AValue: TTime): TValue; inline;
+    class operator = (const ALeft, ARight: TValue): Boolean; inline;
+    class operator <> (const ALeft, ARight: TValue): Boolean; inline;
     property DataSize: SizeInt read GetDataSize;
     property Kind: TTypeKind read GetTypeKind;
     property TypeData: PTypeData read GetTypeDataProp;
@@ -2797,6 +2799,16 @@ begin
   Make(@AValue, System.TypeInfo(TTime), Result);
 end;
 
+class operator TValue.= (const ALeft, ARight: TValue): Boolean;
+begin
+  Result := SameValue(ALeft, ARight);
+end;
+
+class operator TValue.<> (const ALeft, ARight: TValue): Boolean;
+begin
+  Result := not SameValue(ALeft, ARight);
+end;
+
 function TValue.AsString: string;
 begin
   if System.GetTypeKind(String) = tkUString then