implement wxString:IsXXX() methods using iterators

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2007-04-15 10:07:40 +00:00
parent 50f5d508a8
commit a4a44612a6

View File

@ -1604,34 +1604,43 @@ size_t wxString::Replace(const wxString& strOld,
bool wxString::IsAscii() const
{
const wxChar *s = (const wxChar*) *this;
while(*s){
if(!isascii(*s)) return(false);
s++;
}
return(true);
for ( const_iterator i = begin(); i != end(); ++i )
{
if ( !(*i).IsAscii() )
return false;
}
return true;
}
bool wxString::IsWord() const
{
const wxChar *s = (const wxChar*) *this;
while(*s){
if(!wxIsalpha(*s)) return(false);
s++;
}
return(true);
for ( const_iterator i = begin(); i != end(); ++i )
{
if ( !wxIsalpha(*i) )
return false;
}
return true;
}
bool wxString::IsNumber() const
{
const wxChar *s = (const wxChar*) *this;
if (wxStrlen(s))
if ((s[0] == wxT('-')) || (s[0] == wxT('+'))) s++;
while(*s){
if(!wxIsdigit(*s)) return(false);
s++;
}
return(true);
if ( empty() )
return true;
const_iterator i = begin();
if ( *i == _T('-') || *i == _T('+') )
++i;
for ( ; i != end(); ++i )
{
if ( !wxIsdigit(*i) )
return false;
}
return true;
}
wxString wxString::Strip(stripType w) const