Skip to content

Commit 2b71593

Browse files
author
delphidabbler
committed
Added new StrIsEmpty routine
1 parent 80aebb1 commit 2b71593

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Src/UStrUtils.pas

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ function StrBackslashEscape(const S, Escapable, Escapes: string): string;
266266
/// </remarks>
267267
procedure StrArrayToStrList(const SA: array of string; const SL: TStrings);
268268

269+
/// <summary>Checks if the given string is the empty string. If the optional
270+
/// IgnoreWhiteSpace parameter is True then the string is trimmed of leading
271+
/// and trailing white space before checking</summary>
272+
function StrIsEmpty(const S: string; const IgnoreWhiteSpace: Boolean = False):
273+
Boolean;
274+
269275

270276
implementation
271277

@@ -892,5 +898,14 @@ procedure StrArrayToStrList(const SA: array of string; const SL: TStrings);
892898
SL.Add(S);
893899
end;
894900

901+
function StrIsEmpty(const S: string; const IgnoreWhiteSpace: Boolean = False):
902+
Boolean;
903+
begin
904+
if IgnoreWhiteSpace then
905+
Result := StrTrim(S) = ''
906+
else
907+
Result := S = '';
908+
end;
909+
895910
end.
896911

0 commit comments

Comments
 (0)