Refactoring
This commit is contained in:
@@ -78,7 +78,7 @@ type
|
||||
// Creates a new scalar from a kind and a value.
|
||||
constructor Create(AKind: TScalarKind; const AValue: TScalarValue);
|
||||
|
||||
// Factory methods for specific scalar types.
|
||||
// Factory methods for specific scalar types (do not use anymore, these may become deprecated in the future)
|
||||
class function FromInteger(AValue: Integer): TScalar; static; inline;
|
||||
class function FromInt64(AValue: Int64): TScalar; static; inline;
|
||||
class function FromUInt64(AValue: UInt64): TScalar; static; inline;
|
||||
@@ -93,6 +93,17 @@ type
|
||||
class function FromBytes(const AValue: TScalarBytes): TScalar; static; inline;
|
||||
class function FromDecimal(const AValue: TDecimal): TScalar; static; inline;
|
||||
|
||||
// Implicit casts from primitive types to TScalar.
|
||||
class operator Implicit(AValue: Integer): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: Int64): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: UInt64): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: Single): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: Double): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: TDateTime): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: Boolean): TScalar; overload; inline;
|
||||
class operator Implicit(AValue: Char): TScalar; overload; inline;
|
||||
class operator Implicit(const AValue: TDecimal): TScalar; overload; inline;
|
||||
|
||||
class function StringToKind(const AName: string): TScalarKind; static;
|
||||
|
||||
function ToString: String;
|
||||
@@ -405,6 +416,60 @@ begin
|
||||
Result.Value := TScalarValue.FromDouble(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Boolean): TScalar;
|
||||
begin
|
||||
Result.Kind := skBoolean;
|
||||
Result.Value := TScalarValue.FromBoolean(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Char): TScalar;
|
||||
begin
|
||||
Result.Kind := skChar;
|
||||
Result.Value := TScalarValue.FromChar(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: TDateTime): TScalar;
|
||||
begin
|
||||
Result.Kind := skDateTime;
|
||||
Result.Value := TScalarValue.FromDateTime(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(const AValue: TDecimal): TScalar;
|
||||
begin
|
||||
Result.Kind := skDecimal;
|
||||
Result.Value := TScalarValue.FromDecimal(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Double): TScalar;
|
||||
begin
|
||||
Result.Kind := skDouble;
|
||||
Result.Value := TScalarValue.FromDouble(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Int64): TScalar;
|
||||
begin
|
||||
Result.Kind := skInt64;
|
||||
Result.Value := TScalarValue.FromInt64(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Integer): TScalar;
|
||||
begin
|
||||
Result.Kind := skInteger;
|
||||
Result.Value := TScalarValue.FromInteger(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: Single): TScalar;
|
||||
begin
|
||||
Result.Kind := skSingle;
|
||||
Result.Value := TScalarValue.FromSingle(AValue);
|
||||
end;
|
||||
|
||||
class operator TScalar.Implicit(AValue: UInt64): TScalar;
|
||||
begin
|
||||
Result.Kind := skUInt64;
|
||||
Result.Value := TScalarValue.FromUInt64(AValue);
|
||||
end;
|
||||
|
||||
class function TScalar.FromInt64(AValue: Int64): TScalar;
|
||||
begin
|
||||
Result.Kind := skInt64;
|
||||
|
||||
Reference in New Issue
Block a user