mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Added CString::TrimPrefix() and CString::TrimSuffix()
These functions remove prefix/suffix strings if possible. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1224 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -965,6 +965,37 @@ CString CString::TrimRight_n(const CString& s) const {
|
||||
return sRet;
|
||||
}
|
||||
|
||||
bool CString::TrimPrefix(const CString& sPrefix) {
|
||||
if (CaseCmp(sPrefix, sPrefix.length()) == 0) {
|
||||
LeftChomp(sPrefix.length());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CString::TrimSuffix(const CString& sSuffix) {
|
||||
if (Right(sSuffix.length()).CaseCmp(sSuffix) == 0) {
|
||||
RightChomp(sSuffix.length());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CString CString::TrimPrefix_n(const CString& sPrefix) const {
|
||||
CString sRet = *this;
|
||||
sRet.TrimPrefix(sPrefix);
|
||||
return sRet;
|
||||
}
|
||||
|
||||
CString CString::TrimSuffix_n(const CString& sSuffix) const {
|
||||
CString sRet = *this;
|
||||
sRet.TrimSuffix(sSuffix);
|
||||
return sRet;
|
||||
}
|
||||
|
||||
CString CString::LeftChomp_n(unsigned int uLen) const {
|
||||
CString sRet = *this;
|
||||
sRet.LeftChomp(uLen);
|
||||
|
||||
Reference in New Issue
Block a user