Refactoring + Panning in Workspace
This commit is contained in:
@@ -90,9 +90,16 @@ type
|
||||
class function FromBytes(const AValue: TScalarBytes): TScalar; static; inline;
|
||||
class function FromDecimal(const AValue: TDecimal): TScalar; static; inline;
|
||||
|
||||
class function StringToKind(const AName: string): TScalarKind; static;
|
||||
|
||||
function ToString: String;
|
||||
end;
|
||||
|
||||
TScalarKindHelper = record helper for TScalarKind
|
||||
public
|
||||
function ToString: string;
|
||||
end;
|
||||
|
||||
// Basic data structures using the scalar type (these are not POD of course)
|
||||
|
||||
// An array of scalar values of the same kind.
|
||||
@@ -383,6 +390,38 @@ begin
|
||||
Result.Value := TScalarValue.FromUInt64(AValue);
|
||||
end;
|
||||
|
||||
class function TScalar.StringToKind(const AName: string): TScalarKind;
|
||||
begin
|
||||
if SameText(AName, 'integer') then
|
||||
Result := skInteger
|
||||
else if SameText(AName, 'int64') then
|
||||
Result := skInt64
|
||||
else if SameText(AName, 'uint64') then
|
||||
Result := skUInt64
|
||||
else if SameText(AName, 'single') then
|
||||
Result := skSingle
|
||||
else if SameText(AName, 'double') then
|
||||
Result := skDouble
|
||||
else if SameText(AName, 'datetime') then
|
||||
Result := skDateTime
|
||||
else if SameText(AName, 'timestamp') then
|
||||
Result := skTimestamp
|
||||
else if SameText(AName, 'boolean') then
|
||||
Result := skBoolean
|
||||
else if SameText(AName, 'char') then
|
||||
Result := skChar
|
||||
else if SameText(AName, 'pchar') then
|
||||
Result := skPChar
|
||||
else if SameText(AName, 'string') then
|
||||
Result := skString
|
||||
else if SameText(AName, 'bytes') then
|
||||
Result := skBytes
|
||||
else if SameText(AName, 'decimal') then
|
||||
Result := skDecimal
|
||||
else
|
||||
raise EArgumentException.CreateFmt('Unknown scalar type name: "%s"', [AName]);
|
||||
end;
|
||||
|
||||
function TScalar.ToString: String;
|
||||
begin
|
||||
case Kind of
|
||||
@@ -645,6 +684,27 @@ begin
|
||||
Result.Create(FDef, values);
|
||||
end;
|
||||
|
||||
function TScalarKindHelper.ToString: string;
|
||||
begin
|
||||
case Self of
|
||||
skInteger: Result := 'integer';
|
||||
skInt64: Result := 'int64';
|
||||
skUInt64: Result := 'uint64';
|
||||
skSingle: Result := 'single';
|
||||
skDouble: Result := 'double';
|
||||
skDateTime: Result := 'datetime';
|
||||
skTimestamp: Result := 'timestamp';
|
||||
skBoolean: Result := 'boolean';
|
||||
skChar: Result := 'char';
|
||||
skPChar: Result := 'pchar';
|
||||
skString: Result := 'string';
|
||||
skBytes: Result := 'bytes';
|
||||
skDecimal: Result := 'decimal';
|
||||
else
|
||||
Result := 'unknown';
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
Assert(sizeof(TScalarValue) = 8);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user