2020-02-03 10:51:40 +01:00
|
|
|
// ***************************************************************************
|
|
|
|
//
|
|
|
|
// THIS FILE IS GENERATED BY "inv generate-nullables" DO NOT CHANGE MANUALLY!
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
//
|
2020-01-06 16:49:18 +01:00
|
|
|
// *************************************************************************** }
|
|
|
|
//
|
|
|
|
// Delphi MVC Framework
|
|
|
|
//
|
2023-01-17 08:52:26 +01:00
|
|
|
// Copyright (c) 2010-2023 Daniele Teti and the DMVCFramework Team
|
2020-01-06 16:49:18 +01:00
|
|
|
//
|
|
|
|
// https://github.com/danieleteti/delphimvcframework
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2020-02-03 10:51:40 +01:00
|
|
|
|
2020-01-06 16:49:18 +01:00
|
|
|
|
2020-01-04 12:53:53 +01:00
|
|
|
unit MVCFramework.Nullables;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2022-08-01 19:11:42 +02:00
|
|
|
System.SysUtils, System.Classes, System.TypInfo;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
|
|
|
type
|
|
|
|
EMVCNullable = class(Exception)
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
//**************************
|
|
|
|
// ** NullableString
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableString = record
|
|
|
|
private
|
|
|
|
fValue: String;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: String;
|
|
|
|
procedure SetValue(const Value: String);
|
|
|
|
class operator Implicit(const Value: String): NullableString;
|
|
|
|
class operator Implicit(const Value: NullableString): String;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableString;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableString contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableString contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: String;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableString): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: String read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableCurrency
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableCurrency = record
|
|
|
|
private
|
|
|
|
fValue: Currency;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Currency;
|
|
|
|
procedure SetValue(const Value: Currency);
|
|
|
|
class operator Implicit(const Value: Currency): NullableCurrency;
|
|
|
|
class operator Implicit(const Value: NullableCurrency): Currency;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableCurrency;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableCurrency contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableCurrency contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Currency;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableCurrency): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Currency read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableBoolean
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableBoolean = record
|
|
|
|
private
|
|
|
|
fValue: Boolean;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Boolean;
|
|
|
|
procedure SetValue(const Value: Boolean);
|
|
|
|
class operator Implicit(const Value: Boolean): NullableBoolean;
|
|
|
|
class operator Implicit(const Value: NullableBoolean): Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableBoolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableBoolean contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableBoolean contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableBoolean): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Boolean read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableTDate
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableTDate = record
|
|
|
|
private
|
|
|
|
fValue: TDate;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: TDate;
|
|
|
|
procedure SetValue(const Value: TDate);
|
|
|
|
class operator Implicit(const Value: TDate): NullableTDate;
|
|
|
|
class operator Implicit(const Value: NullableTDate): TDate;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableTDate;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTDate contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTDate contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: TDate;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableTDate): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: TDate read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableTTime
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableTTime = record
|
|
|
|
private
|
|
|
|
fValue: TTime;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: TTime;
|
|
|
|
procedure SetValue(const Value: TTime);
|
|
|
|
class operator Implicit(const Value: TTime): NullableTTime;
|
|
|
|
class operator Implicit(const Value: NullableTTime): TTime;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableTTime;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTTime contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTTime contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: TTime;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableTTime): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: TTime read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableTDateTime
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableTDateTime = record
|
|
|
|
private
|
|
|
|
fValue: TDateTime;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: TDateTime;
|
|
|
|
procedure SetValue(const Value: TDateTime);
|
|
|
|
class operator Implicit(const Value: TDateTime): NullableTDateTime;
|
|
|
|
class operator Implicit(const Value: NullableTDateTime): TDateTime;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableTDateTime;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTDateTime contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTDateTime contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: TDateTime;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableTDateTime): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: TDateTime read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableSingle
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableSingle = record
|
|
|
|
private
|
|
|
|
fValue: Single;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Single;
|
|
|
|
procedure SetValue(const Value: Single);
|
|
|
|
class operator Implicit(const Value: Single): NullableSingle;
|
|
|
|
class operator Implicit(const Value: NullableSingle): Single;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableSingle;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableSingle contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableSingle contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Single;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableSingle): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Single read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableDouble
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableDouble = record
|
|
|
|
private
|
|
|
|
fValue: Double;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Double;
|
|
|
|
procedure SetValue(const Value: Double);
|
|
|
|
class operator Implicit(const Value: Double): NullableDouble;
|
|
|
|
class operator Implicit(const Value: NullableDouble): Double;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableDouble;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableDouble contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableDouble contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Double;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableDouble): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Double read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableExtended
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableExtended = record
|
|
|
|
private
|
|
|
|
fValue: Extended;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Extended;
|
|
|
|
procedure SetValue(const Value: Extended);
|
|
|
|
class operator Implicit(const Value: Extended): NullableExtended;
|
|
|
|
class operator Implicit(const Value: NullableExtended): Extended;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableExtended;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableExtended contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableExtended contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Extended;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableExtended): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Extended read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableInt16
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableInt16 = record
|
|
|
|
private
|
|
|
|
fValue: Int16;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Int16;
|
|
|
|
procedure SetValue(const Value: Int16);
|
|
|
|
class operator Implicit(const Value: Int16): NullableInt16;
|
|
|
|
class operator Implicit(const Value: NullableInt16): Int16;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableInt16;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt16 contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt16 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Int16;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableInt16): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Int16 read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
//**************************
|
|
|
|
// ** NullableUInt16
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableUInt16 = record
|
2020-01-04 12:53:53 +01:00
|
|
|
private
|
2020-02-03 10:51:40 +01:00
|
|
|
fValue: UInt16;
|
2020-01-04 12:53:53 +01:00
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-01-04 12:53:53 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
2020-02-03 10:51:40 +01:00
|
|
|
function GetValue: UInt16;
|
|
|
|
procedure SetValue(const Value: UInt16);
|
|
|
|
class operator Implicit(const Value: UInt16): NullableUInt16;
|
|
|
|
class operator Implicit(const Value: NullableUInt16): UInt16;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableUInt16;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt16 contains a value
|
|
|
|
///</summary>
|
2020-01-04 12:53:53 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt16 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-01-04 12:53:53 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-01-04 12:53:53 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: UInt16;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableUInt16): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: UInt16 read GetValue write SetValue;
|
2020-01-04 12:53:53 +01:00
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
//**************************
|
|
|
|
// ** NullableInt32
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableInt32 = record
|
|
|
|
private
|
|
|
|
fValue: Int32;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Int32;
|
|
|
|
procedure SetValue(const Value: Int32);
|
|
|
|
class operator Implicit(const Value: Int32): NullableInt32;
|
|
|
|
class operator Implicit(const Value: NullableInt32): Int32;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableInt32;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt32 contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt32 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Int32;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableInt32): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Int32 read GetValue write SetValue;
|
|
|
|
end;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
//**************************
|
|
|
|
// ** NullableUInt32
|
|
|
|
//**************************
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
NullableUInt32 = record
|
|
|
|
private
|
|
|
|
fValue: UInt32;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: UInt32;
|
|
|
|
procedure SetValue(const Value: UInt32);
|
|
|
|
class operator Implicit(const Value: UInt32): NullableUInt32;
|
|
|
|
class operator Implicit(const Value: NullableUInt32): UInt32;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableUInt32;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt32 contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt32 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: UInt32;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableUInt32): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: UInt32 read GetValue write SetValue;
|
|
|
|
end;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
//**************************
|
|
|
|
// ** NullableInt64
|
|
|
|
//**************************
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
NullableInt64 = record
|
|
|
|
private
|
|
|
|
fValue: Int64;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: Int64;
|
|
|
|
procedure SetValue(const Value: Int64);
|
|
|
|
class operator Implicit(const Value: Int64): NullableInt64;
|
|
|
|
class operator Implicit(const Value: NullableInt64): Int64;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableInt64;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt64 contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableInt64 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: Int64;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableInt64): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: Int64 read GetValue write SetValue;
|
|
|
|
end;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
//**************************
|
|
|
|
// ** NullableUInt64
|
|
|
|
//**************************
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
NullableUInt64 = record
|
|
|
|
private
|
|
|
|
fValue: UInt64;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2020-02-03 10:51:40 +01:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: UInt64;
|
|
|
|
procedure SetValue(const Value: UInt64);
|
|
|
|
class operator Implicit(const Value: UInt64): NullableUInt64;
|
|
|
|
class operator Implicit(const Value: NullableUInt64): UInt64;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableUInt64;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt64 contains a value
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableUInt64 contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
function ValueOrDefault: UInt64;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableUInt64): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2020-02-03 10:51:40 +01:00
|
|
|
property Value: UInt64 read GetValue write SetValue;
|
|
|
|
end;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
2022-06-16 14:05:01 +02:00
|
|
|
//**************************
|
|
|
|
// ** NullableTGUID
|
|
|
|
//**************************
|
|
|
|
|
|
|
|
NullableTGUID = record
|
|
|
|
private
|
|
|
|
fValue: TGUID;
|
|
|
|
fHasValue: String;
|
|
|
|
function GetHasValue: Boolean;
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetIsNull: Boolean;
|
2022-06-16 14:05:01 +02:00
|
|
|
public
|
|
|
|
procedure CheckHasValue;
|
|
|
|
function GetValue: TGUID;
|
|
|
|
procedure SetValue(const Value: TGUID);
|
|
|
|
class operator Implicit(const Value: TGUID): NullableTGUID;
|
|
|
|
class operator Implicit(const Value: NullableTGUID): TGUID;
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator Implicit(const Value: Pointer): NullableTGUID;
|
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTGUID contains a value
|
|
|
|
///</summary>
|
2022-06-16 14:05:01 +02:00
|
|
|
property HasValue: Boolean read GetHasValue;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns `True` if the NullableTGUID contains a null
|
|
|
|
///</summary>
|
|
|
|
property IsNull: Boolean read GetIsNull;
|
|
|
|
///<summary>
|
|
|
|
///Alias of `SetNull`
|
|
|
|
///</summary>
|
2022-06-16 14:05:01 +02:00
|
|
|
procedure Clear;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Set the value to `null`
|
|
|
|
///</summary>
|
2022-06-16 14:05:01 +02:00
|
|
|
procedure SetNull;
|
2022-08-01 19:11:42 +02:00
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or the default value for the type is the value is not set
|
|
|
|
///</summary>
|
2022-06-16 14:05:01 +02:00
|
|
|
function ValueOrDefault: TGUID;
|
2022-08-01 19:11:42 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true is both item have the same value and that value is not null.
|
|
|
|
/// </summary>
|
|
|
|
function Equals(const Value: NullableTGUID): Boolean;
|
|
|
|
///<summary>
|
|
|
|
///Returns the value stored or raises exception if no value is stored
|
|
|
|
///</summary>
|
2022-06-16 14:05:01 +02:00
|
|
|
property Value: TGUID read GetValue write SetValue;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
TNullableType = (
|
|
|
|
ntInvalidNullableType
|
|
|
|
, ntNullableString
|
|
|
|
, ntNullableCurrency
|
|
|
|
, ntNullableBoolean
|
|
|
|
, ntNullableTDate
|
|
|
|
, ntNullableTTime
|
|
|
|
, ntNullableTDateTime
|
|
|
|
, ntNullableSingle
|
|
|
|
, ntNullableDouble
|
|
|
|
, ntNullableExtended
|
|
|
|
, ntNullableInt16
|
|
|
|
, ntNullableUInt16
|
|
|
|
, ntNullableInt32
|
|
|
|
, ntNullableUInt32
|
|
|
|
, ntNullableInt64
|
|
|
|
, ntNullableUInt64
|
|
|
|
, ntNullableTGUID);
|
|
|
|
|
|
|
|
|
|
|
|
function GetNullableType(const aTypeInfo: PTypeInfo): TNullableType;
|
2020-01-04 12:53:53 +01:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
{ NullableString }
|
|
|
|
|
|
|
|
procedure NullableString.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableString.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableString.Equals(const Value: NullableString): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableString.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableString.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableString.GetValue: String;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableString.Implicit(const Value: NullableString): String;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableString.Implicit(const Value: String): NullableString;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableString.Implicit(const Value: Pointer): NullableString;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableString.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (String);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableString.SetValue(const Value: String);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableString.ValueOrDefault: String;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (String);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableCurrency }
|
|
|
|
|
|
|
|
procedure NullableCurrency.CheckHasValue;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableCurrency.Clear;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableCurrency.Equals(const Value: NullableCurrency): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableCurrency.GetHasValue: Boolean;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableCurrency.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableCurrency.GetValue: Currency;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
class operator NullableCurrency.Implicit(const Value: NullableCurrency): Currency;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
class operator NullableCurrency.Implicit(const Value: Currency): NullableCurrency;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableCurrency.Implicit(const Value: Pointer): NullableCurrency;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableCurrency.SetNull;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
2020-02-03 10:51:40 +01:00
|
|
|
fValue := Default (Currency);
|
2020-01-04 12:53:53 +01:00
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableCurrency.SetValue(const Value: Currency);
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableCurrency.ValueOrDefault: Currency;
|
2020-01-04 12:53:53 +01:00
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2020-02-03 10:51:40 +01:00
|
|
|
Result := Default (Currency);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableBoolean }
|
|
|
|
|
|
|
|
procedure NullableBoolean.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
2020-01-04 12:53:53 +01:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableBoolean.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableBoolean.Equals(const Value: NullableBoolean): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableBoolean.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableBoolean.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableBoolean.GetValue: Boolean;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableBoolean.Implicit(const Value: NullableBoolean): Boolean;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableBoolean.Implicit(const Value: Boolean): NullableBoolean;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableBoolean.Implicit(const Value: Pointer): NullableBoolean;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableBoolean.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Boolean);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableBoolean.SetValue(const Value: Boolean);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableBoolean.ValueOrDefault: Boolean;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Boolean);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableTDate }
|
|
|
|
|
|
|
|
procedure NullableTDate.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTDate.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDate.Equals(const Value: NullableTDate): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDate.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableTDate.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableTDate.GetValue: TDate;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTDate.Implicit(const Value: NullableTDate): TDate;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTDate.Implicit(const Value: TDate): NullableTDate;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableTDate.Implicit(const Value: Pointer): NullableTDate;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableTDate.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (TDate);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTDate.SetValue(const Value: TDate);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDate.ValueOrDefault: TDate;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (TDate);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableTTime }
|
|
|
|
|
|
|
|
procedure NullableTTime.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTTime.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTTime.Equals(const Value: NullableTTime): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTTime.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableTTime.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableTTime.GetValue: TTime;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTTime.Implicit(const Value: NullableTTime): TTime;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTTime.Implicit(const Value: TTime): NullableTTime;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableTTime.Implicit(const Value: Pointer): NullableTTime;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableTTime.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (TTime);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTTime.SetValue(const Value: TTime);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTTime.ValueOrDefault: TTime;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (TTime);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableTDateTime }
|
|
|
|
|
|
|
|
procedure NullableTDateTime.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTDateTime.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDateTime.Equals(const Value: NullableTDateTime): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDateTime.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableTDateTime.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableTDateTime.GetValue: TDateTime;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTDateTime.Implicit(const Value: NullableTDateTime): TDateTime;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTDateTime.Implicit(const Value: TDateTime): NullableTDateTime;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableTDateTime.Implicit(const Value: Pointer): NullableTDateTime;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableTDateTime.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (TDateTime);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTDateTime.SetValue(const Value: TDateTime);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTDateTime.ValueOrDefault: TDateTime;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (TDateTime);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableSingle }
|
|
|
|
|
|
|
|
procedure NullableSingle.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableSingle.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableSingle.Equals(const Value: NullableSingle): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableSingle.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableSingle.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableSingle.GetValue: Single;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableSingle.Implicit(const Value: NullableSingle): Single;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableSingle.Implicit(const Value: Single): NullableSingle;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableSingle.Implicit(const Value: Pointer): NullableSingle;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableSingle.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Single);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableSingle.SetValue(const Value: Single);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableSingle.ValueOrDefault: Single;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Single);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableDouble }
|
|
|
|
|
|
|
|
procedure NullableDouble.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableDouble.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableDouble.Equals(const Value: NullableDouble): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableDouble.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableDouble.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableDouble.GetValue: Double;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableDouble.Implicit(const Value: NullableDouble): Double;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableDouble.Implicit(const Value: Double): NullableDouble;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableDouble.Implicit(const Value: Pointer): NullableDouble;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableDouble.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Double);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableDouble.SetValue(const Value: Double);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableDouble.ValueOrDefault: Double;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Double);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableExtended }
|
|
|
|
|
|
|
|
procedure NullableExtended.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableExtended.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableExtended.Equals(const Value: NullableExtended): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableExtended.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableExtended.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableExtended.GetValue: Extended;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableExtended.Implicit(const Value: NullableExtended): Extended;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableExtended.Implicit(const Value: Extended): NullableExtended;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableExtended.Implicit(const Value: Pointer): NullableExtended;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableExtended.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Extended);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableExtended.SetValue(const Value: Extended);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableExtended.ValueOrDefault: Extended;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Extended);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableInt16 }
|
|
|
|
|
|
|
|
procedure NullableInt16.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt16.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt16.Equals(const Value: NullableInt16): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt16.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableInt16.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableInt16.GetValue: Int16;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt16.Implicit(const Value: NullableInt16): Int16;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt16.Implicit(const Value: Int16): NullableInt16;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableInt16.Implicit(const Value: Pointer): NullableInt16;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableInt16.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Int16);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt16.SetValue(const Value: Int16);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt16.ValueOrDefault: Int16;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Int16);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableUInt16 }
|
|
|
|
|
|
|
|
procedure NullableUInt16.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt16.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt16.Equals(const Value: NullableUInt16): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt16.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableUInt16.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableUInt16.GetValue: UInt16;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt16.Implicit(const Value: NullableUInt16): UInt16;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt16.Implicit(const Value: UInt16): NullableUInt16;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableUInt16.Implicit(const Value: Pointer): NullableUInt16;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableUInt16.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (UInt16);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt16.SetValue(const Value: UInt16);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt16.ValueOrDefault: UInt16;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (UInt16);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableInt32 }
|
|
|
|
|
|
|
|
procedure NullableInt32.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt32.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt32.Equals(const Value: NullableInt32): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt32.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableInt32.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableInt32.GetValue: Int32;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt32.Implicit(const Value: NullableInt32): Int32;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt32.Implicit(const Value: Int32): NullableInt32;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableInt32.Implicit(const Value: Pointer): NullableInt32;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableInt32.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Int32);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt32.SetValue(const Value: Int32);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt32.ValueOrDefault: Int32;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Int32);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableUInt32 }
|
|
|
|
|
|
|
|
procedure NullableUInt32.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt32.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt32.Equals(const Value: NullableUInt32): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt32.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableUInt32.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableUInt32.GetValue: UInt32;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt32.Implicit(const Value: NullableUInt32): UInt32;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt32.Implicit(const Value: UInt32): NullableUInt32;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableUInt32.Implicit(const Value: Pointer): NullableUInt32;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableUInt32.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (UInt32);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt32.SetValue(const Value: UInt32);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt32.ValueOrDefault: UInt32;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (UInt32);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableInt64 }
|
|
|
|
|
|
|
|
procedure NullableInt64.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt64.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt64.Equals(const Value: NullableInt64): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt64.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableInt64.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableInt64.GetValue: Int64;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt64.Implicit(const Value: NullableInt64): Int64;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableInt64.Implicit(const Value: Int64): NullableInt64;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableInt64.Implicit(const Value: Pointer): NullableInt64;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableInt64.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (Int64);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableInt64.SetValue(const Value: Int64);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableInt64.ValueOrDefault: Int64;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (Int64);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NullableUInt64 }
|
|
|
|
|
|
|
|
procedure NullableUInt64.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt64.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt64.Equals(const Value: NullableUInt64): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt64.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableUInt64.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
function NullableUInt64.GetValue: UInt64;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt64.Implicit(const Value: NullableUInt64): UInt64;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableUInt64.Implicit(const Value: UInt64): NullableUInt64;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableUInt64.Implicit(const Value: Pointer): NullableUInt64;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-02-03 10:51:40 +01:00
|
|
|
procedure NullableUInt64.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (UInt64);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableUInt64.SetValue(const Value: UInt64);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableUInt64.ValueOrDefault: UInt64;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (UInt64);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-16 14:05:01 +02:00
|
|
|
{ NullableTGUID }
|
|
|
|
|
|
|
|
procedure NullableTGUID.CheckHasValue;
|
|
|
|
begin
|
|
|
|
if not GetHasValue then
|
|
|
|
begin
|
|
|
|
raise EMVCNullable.Create('Value is null');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTGUID.Clear;
|
|
|
|
begin
|
|
|
|
SetNull;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTGUID.Equals(const Value: NullableTGUID): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTGUID.GetHasValue: Boolean;
|
|
|
|
begin
|
|
|
|
Result := fHasValue = '_';
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function NullableTGUID.GetIsNull: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not HasValue;
|
|
|
|
end;
|
|
|
|
|
2022-06-16 14:05:01 +02:00
|
|
|
function NullableTGUID.GetValue: TGUID;
|
|
|
|
begin
|
|
|
|
CheckHasValue;
|
|
|
|
Result := fValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTGUID.Implicit(const Value: NullableTGUID): TGUID;
|
|
|
|
begin
|
|
|
|
Result := Value.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class operator NullableTGUID.Implicit(const Value: TGUID): NullableTGUID;
|
|
|
|
begin
|
|
|
|
Result.Value := Value;
|
|
|
|
end;
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
class operator NullableTGUID.Implicit(const Value: Pointer): NullableTGUID;
|
|
|
|
begin
|
|
|
|
if Value = nil then
|
|
|
|
begin
|
|
|
|
Result.SetNull;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
raise EInvalidPointer.Create('Pointer value can only be "nil"');
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2022-06-16 14:05:01 +02:00
|
|
|
procedure NullableTGUID.SetNull;
|
|
|
|
begin
|
|
|
|
fValue := Default (TGUID);
|
|
|
|
fHasValue := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure NullableTGUID.SetValue(const Value: TGUID);
|
|
|
|
begin
|
|
|
|
fValue := Value;
|
|
|
|
fHasValue := '_';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function NullableTGUID.ValueOrDefault: TGUID;
|
|
|
|
begin
|
|
|
|
if HasValue then
|
|
|
|
begin
|
|
|
|
Result := GetValue
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := Default (TGUID);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2022-08-01 19:11:42 +02:00
|
|
|
function GetNullableType(const aTypeInfo: PTypeInfo): TNullableType;
|
|
|
|
begin
|
|
|
|
if aTypeInfo = TypeInfo(NullableString) then
|
|
|
|
Exit(ntNullableString);
|
|
|
|
if aTypeInfo = TypeInfo(NullableCurrency) then
|
|
|
|
Exit(ntNullableCurrency);
|
|
|
|
if aTypeInfo = TypeInfo(NullableBoolean) then
|
|
|
|
Exit(ntNullableBoolean);
|
|
|
|
if aTypeInfo = TypeInfo(NullableTDate) then
|
|
|
|
Exit(ntNullableTDate);
|
|
|
|
if aTypeInfo = TypeInfo(NullableTTime) then
|
|
|
|
Exit(ntNullableTTime);
|
|
|
|
if aTypeInfo = TypeInfo(NullableTDateTime) then
|
|
|
|
Exit(ntNullableTDateTime);
|
|
|
|
if aTypeInfo = TypeInfo(NullableSingle) then
|
|
|
|
Exit(ntNullableSingle);
|
|
|
|
if aTypeInfo = TypeInfo(NullableDouble) then
|
|
|
|
Exit(ntNullableDouble);
|
|
|
|
if aTypeInfo = TypeInfo(NullableExtended) then
|
|
|
|
Exit(ntNullableExtended);
|
|
|
|
if aTypeInfo = TypeInfo(NullableInt16) then
|
|
|
|
Exit(ntNullableInt16);
|
|
|
|
if aTypeInfo = TypeInfo(NullableUInt16) then
|
|
|
|
Exit(ntNullableUInt16);
|
|
|
|
if aTypeInfo = TypeInfo(NullableInt32) then
|
|
|
|
Exit(ntNullableInt32);
|
|
|
|
if aTypeInfo = TypeInfo(NullableUInt32) then
|
|
|
|
Exit(ntNullableUInt32);
|
|
|
|
if aTypeInfo = TypeInfo(NullableInt64) then
|
|
|
|
Exit(ntNullableInt64);
|
|
|
|
if aTypeInfo = TypeInfo(NullableUInt64) then
|
|
|
|
Exit(ntNullableUInt64);
|
|
|
|
if aTypeInfo = TypeInfo(NullableTGUID) then
|
|
|
|
Exit(ntNullableTGUID);
|
|
|
|
Result := ntInvalidNullableType;
|
|
|
|
end;
|
2022-06-16 14:05:01 +02:00
|
|
|
|
2020-01-04 12:53:53 +01:00
|
|
|
end.
|
2022-08-01 19:11:42 +02:00
|
|
|
|