Browse Source

Add methods for testing casing of `BaseText`'s charracters

core_refactor
Anton Tarasenko 2 years ago
parent
commit
e562072a90
  1. 48
      sources/Text/BaseText.uc

48
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.
*

Loading…
Cancel
Save