From f40b3e78d78c52704a11974b1a1bfd11ba7abae0 Mon Sep 17 00:00:00 2001 From: kroimon Date: Tue, 30 Sep 2008 12:58:34 +0000 Subject: [PATCH] Added CString::Equals() This new function can be used to replace the old (CaseCmp() == 0) statements. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1232 726aef4b-f618-498e-8847-2d620e286838 --- ZNCString.cpp | 7 +++++++ ZNCString.h | 1 + 2 files changed, 8 insertions(+) diff --git a/ZNCString.cpp b/ZNCString.cpp index fa7f9169..353b9169 100644 --- a/ZNCString.cpp +++ b/ZNCString.cpp @@ -186,6 +186,13 @@ int CString::StrCmp(const CString& s, unsigned long uLen) const { return strcmp(c_str(), s.c_str()); } +bool CString::Equals(const CString& s, bool bCaseSensitive, unsigned long uLen) const { + if (bCaseSensitive) + return (StrCmp(s, uLen) == 0); + else + return (CaseCmp(s, uLen) == 0); +} + bool CString::WildCmp(const CString& sWild, const CString& sString) { // Written by Jack Handy - jakkhandy@hotmail.com const char *wild = sWild.c_str(), *CString = sString.c_str(); diff --git a/ZNCString.h b/ZNCString.h index 48e8f57f..7b693fea 100644 --- a/ZNCString.h +++ b/ZNCString.h @@ -82,6 +82,7 @@ public: inline unsigned char* strnchr(const unsigned char* src, unsigned char c, unsigned int iMaxBytes, unsigned char* pFill = NULL, unsigned int* piCount = NULL) const; int CaseCmp(const CString& s, unsigned long uLen = CString::npos) const; int StrCmp(const CString& s, unsigned long uLen = CString::npos) const; + bool Equals(const CString& s, bool bCaseSensitive = false, unsigned long uLen = CString::npos) const; static bool WildCmp(const CString& sWild, const CString& sString); bool WildCmp(const CString& sWild) const;