Skip to content

Commit 830a888

Browse files
committed
Add new TSnippetList.IsEmpty(Boolean) method override;
The Boolean parameter specifies whether we're checking User defined database (True) or main database (False) for emptiness.
1 parent d20d9fd commit 830a888

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Src/DB.USnippet.pas

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at https://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2011-2021, Peter Johnson (gravatar.com/delphidabbler).
6+
* Copyright (C) 2011-2022, Peter Johnson (gravatar.com/delphidabbler).
77
*
88
* Objects, records etc that encapsulate a code snippet, its data and lists of
99
* code snippets.
@@ -328,10 +328,17 @@ TSnippetList = class(TObject)
328328
{Counts number of snippets in list.
329329
@return Number of snippets in list.
330330
}
331-
function IsEmpty: Boolean; inline;
331+
function IsEmpty: Boolean; overload; inline;
332332
{Checks if list is empty.
333333
@return True if list is empty, False otehrwise.
334334
}
335+
function IsEmpty(const UserDefined: Boolean): Boolean; overload; inline;
336+
{Checks if sub-set of list from either from or not from use defined
337+
database is empty.
338+
@param UserDefined [in] Flags whether to check for snippets in user
339+
database (True) or in main database (False).
340+
@return True if required subset is empty, False if not empty.
341+
}
335342
property Items[Idx: Integer]: TSnippet read GetItem; default;
336343
{List of snippets}
337344
end;
@@ -764,6 +771,11 @@ function TSnippetList.IsEmpty: Boolean;
764771
Result := Count = 0;
765772
end;
766773

774+
function TSnippetList.IsEmpty(const UserDefined: Boolean): Boolean;
775+
begin
776+
Result := Count(UserDefined) = 0;
777+
end;
778+
767779
function TSnippetList.IsEqual(const AList: TSnippetList): Boolean;
768780
{Checks if this list contains same snippets as another list.
769781
@param AList [in] List of snippets to compare.

0 commit comments

Comments
 (0)