Data Types

This commit is contained in:
Michael Schimmel
2025-08-25 18:00:15 +02:00
parent 42110e8471
commit 947060566d
11 changed files with 642 additions and 28 deletions
+38 -1
View File
@@ -25,7 +25,8 @@ type
implementation
uses
System.Math;
System.Math,
System.Rtti;
type
// Implements the float data value.
@@ -38,6 +39,7 @@ type
// IDataValue
function GetDataType: IDataType;
function GetAsString: string;
function AsTValue: TValue;
// IDataFloatValue
function GetValue: Double;
@@ -45,18 +47,28 @@ type
// Special implementation for the value 0.0 (Singleton)
TDataFloatValueZero = class(TInterfacedObject, IDataValue, IDataFloatValue)
strict private
class var
FValue: TValue;
class constructor CreateClass;
public
function GetDataType: IDataType;
function GetAsString: string;
function GetValue: Double;
function AsTValue: TValue;
end;
// Special implementation for NaN (Not a Number) (Singleton)
TDataFloatValueNaN = class(TInterfacedObject, IDataValue, IDataFloatValue)
strict private
class var
FValue: TValue;
class constructor CreateClass;
public
function GetDataType: IDataType;
function GetAsString: string;
function GetValue: Double;
function AsTValue: TValue;
end;
{ TDataFloatValue }
@@ -77,6 +89,11 @@ begin
Result := FloatToStr(FValue);
end;
function TDataFloatValue.AsTValue: TValue;
begin
Result := TValue.From<Double>(FValue);
end;
function TDataFloatValue.GetValue: Double;
begin
Result := FValue;
@@ -84,6 +101,11 @@ end;
{ TDataFloatValueZero }
class constructor TDataFloatValueZero.CreateClass;
begin
FValue := TValue.From<Double>(0.0);
end;
function TDataFloatValueZero.GetAsString: string;
begin
Result := '0';
@@ -99,8 +121,18 @@ begin
Result := 0.0;
end;
function TDataFloatValueZero.AsTValue: TValue;
begin
Result := FValue;
end;
{ TDataFloatValueNaN }
class constructor TDataFloatValueNaN.CreateClass;
begin
FValue := TValue.From<Double>(NaN);
end;
function TDataFloatValueNaN.GetAsString: string;
begin
Result := 'NaN';
@@ -116,6 +148,11 @@ begin
Result := NaN;
end;
function TDataFloatValueNaN.AsTValue: TValue;
begin
Result := FValue;
end;
{ TDataFloatType }
class constructor TDataFloatType.CreateClass;