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:
1 parent
038961359e
commit
e693acaa66
2 files changed
+36
No files matched your search
@@ -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