From e562072a9068e23ee173ef05ef857071834e2961 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 6 Mar 2023 03:13:04 +0700 Subject: [PATCH] Add methods for testing casing of `BaseText`'s charracters --- sources/Text/BaseText.uc | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sources/Text/BaseText.uc b/sources/Text/BaseText.uc index cc5bec7..218788e 100644 --- a/sources/Text/BaseText.uc +++ b/sources/Text/BaseText.uc @@ -404,6 +404,54 @@ public final function MutableText UpperMutableCopy( return textCopy; } +/** + * Checks whether all letters in the caller text is in the lower case. + * + * @return `true` if there are no characters that qualify as upper case and + * `false` otherwise. + */ +public final function bool IsLowerCase() +{ + local int i; + local Character nextCharacter; + + if (IsEmpty()) { + return true; + } + for (i = 0; i < GetLength(); i += 1) + { + nextCharacter = GetCharacter(i); + if (_.text.IsUpper(nextCharacter)) { + return false; + } + } + return true; +} + +/** + * Checks whether all letters in the caller text is in the lower case. + * + * @return `true` if there are no characters that qualify as lower case and + * `false` otherwise. + */ +public final function bool IsUpperCase() +{ + local int i; + local Character nextCharacter; + + if (IsEmpty()) { + return true; + } + for (i = 0; i < GetLength(); i += 1) + { + nextCharacter = GetCharacter(i); + if (_.text.IsLower(nextCharacter)) { + return false; + } + } + return true; +} + /** * Checks if caller `BaseText` contains a valid name object or not. *