Skip to content

Commit

Permalink
Update Neon.Core.Nullables.pas
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsbejatto committed Dec 24, 2024
1 parent 0b0ed71 commit 0e2e329
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions Source/Neon.Core.Nullables.pas
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
{******************************************************************************}
{ }
{ Neon: Serialization Library for Delphi }
{ Copyright (c) 2018 Paolo Rossi }
{ https://github.com/paolo-rossi/neon-library }
{ }
{******************************************************************************}
{ }
{ 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. }
{ }
{******************************************************************************}
unit Neon.Core.Nullables;

{$I Neon.inc}

interface

uses
Expand All @@ -42,6 +19,7 @@ Nullable<T> = record
function GetValue: T;
procedure SetValue(const AValue: T);
function GetHasValue: Boolean;
class function VarIsNullOrEmpty(const Value: Variant): Boolean; static;
public
constructor Create(const Value: T); overload;
constructor Create(const Value: Variant); overload;
Expand Down Expand Up @@ -71,20 +49,23 @@ Nullable<T> = record
class operator NotEqual(const Left: T; Right: Nullable<T>): Boolean; overload;
class operator GreaterThan(const Left: Nullable<T>; Right: T): Boolean; overload;
class operator LessThan(const Left: Nullable<T>; Right: T): Boolean; overload;

end;

NullString = Nullable<string>;
NullBoolean = Nullable<Boolean>;
NullInteger = Nullable<Integer>;
NullInt64 = Nullable<Int64>;
NullDouble = Nullable<Double>;
NullDateTime = Nullable<TDateTime>;
NullCurrency = Nullable<Currency>;
NullDate = Nullable<TDate>;
NullTime = Nullable<TTime>;
NullDateTime = Nullable<TDateTime>;

implementation

uses
Neon.Core.Utils;
const
CHasValueFlag = '@';

{ Nullable<T> }

Expand Down Expand Up @@ -268,4 +249,9 @@ function Nullable<T>.ToVariant: Variant;
end;


class function Nullable<T>.VarIsNullOrEmpty(const Value: Variant): Boolean;
begin
Result := VarIsNull(Value) or VarIsEmpty(Value);
end;

end.

0 comments on commit 0e2e329

Please sign in to comment.