// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "string.h"
#endif
return find(wxStringBase(sz, n), nStart);
}
-// Gives a duplicate symbol (presumably a case-insensitivity problem)
-#if !defined(__BORLANDC__)
size_t wxStringBase::find(wxChar ch, size_t nStart) const
{
wxASSERT( nStart <= length() );
return p == NULL ? npos : p - c_str();
}
-#endif
size_t wxStringBase::rfind(const wxStringBase& str, size_t nStart) const
{
wxASSERT( nStart <= length() );
}
- const wxChar *p = wxStrrchr(c_str(), ch);
-
- if ( p == NULL )
- return npos;
+ const wxChar *actual;
+ for ( actual = c_str() + ( nStart == npos ? length() : nStart + 1 );
+ actual > c_str(); --actual )
+ {
+ if ( *(actual - 1) == ch )
+ return (actual - 1) - c_str();
+ }
- size_t result = p - c_str();
- return ( result > nStart ) ? npos : result;
+ return npos;
}
size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart) const
}
else
{
- wxASSERT( nStart <= length() );
+ wxASSERT_MSG( nStart <= length(),
+ _T("invalid index in find_last_of()") );
}
- for ( const wxChar *p = c_str() + length() - 1; p >= c_str(); p-- )
+ for ( const wxChar *p = c_str() + nStart - 1; p >= c_str(); p-- )
{
if ( wxStrchr(sz, *p) )
return p - c_str();
wxDELETEA(m_pItems);
}
+void wxArrayString::reserve(size_t nSize)
+{
+ Alloc(nSize);
+}
+
// pre-allocates memory (frees the previous data!)
void wxArrayString::Alloc(size_t nSize)
{