New type system

This commit is contained in:
Michael Schimmel
2025-08-26 15:49:28 +02:00
parent e9608a746a
commit 54d470b2f8
15 changed files with 58 additions and 364 deletions
+37
View File
@@ -0,0 +1,37 @@
unit Myc.Data.Types.RTTI;
interface
uses
System.SysUtils,
System.RTTI,
Myc.Data.Types;
type
TValueHelper = record helper for TDataType.TValue
function AsTValue: TValue;
end;
implementation
uses
System.Math;
{ TValueHelper }
function TValueHelper.AsTValue: TValue;
begin
case DataType.Kind of
dkVoid: Result := TValue.Empty;
dkOrdinal: Result := TValue.From<Int64>(AsOrdinal.Value);
dkFloat: Result := TValue.From<Double>(AsFloat.Value);
dkText: Result := TValue.From<string>(AsText.Value);
dkTimestamp: Result := TValue.From<TDateTime>(AsTimestamp.Value);
dkEnum: Result := TValue.From<Integer>(AsEnum.Value);
dkMethod: Result := TValue.From<TDataMethodProc>(AsMethod.Value);
else
raise EInvalidOpException.Create('Unsupported data type');
end;
end;
end.