added wxString::EndsWith() (patch 1483049)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-05-06 17:27:52 +00:00
parent 9b2a74693e
commit 3affcd078b
5 changed files with 65 additions and 10 deletions

View File

@@ -1394,6 +1394,27 @@ bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const
return true;
}
// check that the string ends with suffix and return the rest of it in the
// provided pointer if it is not NULL, otherwise return false
bool wxString::EndsWith(const wxChar *suffix, wxString *rest) const
{
wxASSERT_MSG( suffix, _T("invalid parameter in wxString::EndssWith") );
int start = length() - wxStrlen(suffix);
if ( start < 0 || wxStrcmp(c_str() + start, suffix) != 0 )
return false;
if ( rest )
{
// put the rest of the string into provided pointer
rest->assign(*this, 0, start);
}
return true;
}
// extract nCount last (rightmost) characters
wxString wxString::Right(size_t nCount) const
{