Type System

This commit is contained in:
Michael Schimmel
2025-08-26 11:06:35 +02:00
parent e4681e2bf7
commit 5adbe67d0b
15 changed files with 1426 additions and 612 deletions
+16 -16
View File
@@ -7,7 +7,7 @@ uses
Myc.Data.Types;
type
TDataTimestampType = class(TInterfacedObject, IDataType, IDataTimestampType)
TImplDataTimestampType = class(TInterfacedObject, IDataType, IDataTimestampType)
strict private
class var
FSingleton: IDataTimestampType;
@@ -25,7 +25,7 @@ uses
System.Rtti;
type
TDataTimestampValue = class(TInterfacedObject, IDataValue, IDataTimestampValue)
TImplDataTimestampValue = class(TInterfacedObject, IDataValue, IDataTimestampValue)
private
FValue: TDateTime;
function GetDataType: IDataType;
@@ -36,52 +36,52 @@ type
constructor Create(const AValue: TDateTime);
end;
{ TDataTimestampType }
{ TImplDataTimestampType }
class constructor TDataTimestampType.CreateClass;
class constructor TImplDataTimestampType.CreateClass;
begin
FSingleton := TDataTimestampType.Create;
FSingleton := TImplDataTimestampType.Create;
end;
function TDataTimestampType.CreateValue(const AValue: TDateTime): IDataTimestampValue;
function TImplDataTimestampType.CreateValue(const AValue: TDateTime): IDataTimestampValue;
begin
Result := TDataTimestampValue.Create(AValue);
Result := TImplDataTimestampValue.Create(AValue);
end;
function TDataTimestampType.GetName: String;
function TImplDataTimestampType.GetName: String;
begin
Result := 'Timestamp';
end;
function TDataTimestampType.GetKind: TDataKind;
function TImplDataTimestampType.GetKind: TDataKind;
begin
Result := dkTimestamp;
end;
{ TDataTimestampValue }
{ TImplDataTimestampValue }
constructor TDataTimestampValue.Create(const AValue: TDateTime);
constructor TImplDataTimestampValue.Create(const AValue: TDateTime);
begin
inherited Create;
FValue := AValue;
end;
function TDataTimestampValue.GetDataType: IDataType;
function TImplDataTimestampValue.GetDataType: IDataType;
begin
Result := TDataTimestampType.Singleton;
Result := TImplDataTimestampType.Singleton;
end;
function TDataTimestampValue.GetAsString: string;
function TImplDataTimestampValue.GetAsString: string;
begin
Result := DateTimeToStr(FValue);
end;
function TDataTimestampValue.GetValue: TDateTime;
function TImplDataTimestampValue.GetValue: TDateTime;
begin
Result := FValue;
end;
function TDataTimestampValue.AsTValue: TValue;
function TImplDataTimestampValue.AsTValue: TValue;
begin
Result := TValue.From<TDateTime>(FValue);
end;