Introduce CaseSensitivity enum class

The enum is a bit more verbose, but leads to more readable code:

str.Equals("foo", true)
// vs.
str.Equals("foo", CString::CaseSensitive)

Deprecate the old Equals() and leave out the length parameter
from the new version => use StartsWith() or StrCmp() instead.
This commit is contained in:
J-P Nurmi
2014-09-29 16:10:26 +02:00
parent 227f2cfb29
commit e86f43d841
3 changed files with 31 additions and 4 deletions

View File

@@ -79,6 +79,14 @@ int CString::StrCmp(const CString& s, CString::size_type uLen) const {
return strcmp(c_str(), s.c_str());
}
bool CString::Equals(const CString& s, CaseSensitivity cs) const {
if (cs == CaseSensitive) {
return (StrCmp(s) == 0);
} else {
return (CaseCmp(s) == 0);
}
}
bool CString::Equals(const CString& s, bool bCaseSensitive, CString::size_type uLen) const {
if (bCaseSensitive) {
return (StrCmp(s, uLen) == 0);