merged in the commit from the 2.2 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-10-04 23:38:26 +00:00
parent 3438012b66
commit fb20fa43a0
2 changed files with 38 additions and 8 deletions

View File

@@ -855,7 +855,7 @@ public:
#if !defined(__VISUALC__) || defined(__WIN32__) #if !defined(__VISUALC__) || defined(__WIN32__)
// find first n characters of sz // find first n characters of sz
size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const; size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const;
#endif #endif // VC++ 1.5
// Gives a duplicate symbol (presumably a case-insensitivity problem) // Gives a duplicate symbol (presumably a case-insensitivity problem)
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
@@ -874,7 +874,7 @@ public:
size_t n = npos) const; size_t n = npos) const;
// as find, but from the end // as find, but from the end
size_t rfind(wxChar ch, size_t nStart = npos) const; size_t rfind(wxChar ch, size_t nStart = npos) const;
#endif #endif // VC++ 1.5
// find first/last occurence of any character in the set // find first/last occurence of any character in the set
@@ -905,7 +905,8 @@ public:
// same as above // same as above
size_t find_first_not_of(wxChar ch, size_t nStart = 0) const; size_t find_first_not_of(wxChar ch, size_t nStart = 0) const;
// as strcspn() // as strcspn()
size_t find_last_not_of(const wxString& str, size_t nStart=npos) const; size_t find_last_not_of(const wxString& str, size_t nStart = npos) const
{ return find_first_not_of(str.c_str(), nStart); }
// same as above // same as above
size_t find_last_not_of(const wxChar* sz, size_t nStart = npos) const; size_t find_last_not_of(const wxChar* sz, size_t nStart = npos) const;
// same as above // same as above
@@ -917,15 +918,18 @@ public:
// just like strcmp() // just like strcmp()
int compare(const wxString& str) const { return Cmp(str); } int compare(const wxString& str) const { return Cmp(str); }
// comparison with a substring // comparison with a substring
int compare(size_t nStart, size_t nLen, const wxString& str) const; int compare(size_t nStart, size_t nLen, const wxString& str) const
{ return Mid(nStart, nLen).Cmp(str); }
// comparison of 2 substrings // comparison of 2 substrings
int compare(size_t nStart, size_t nLen, int compare(size_t nStart, size_t nLen,
const wxString& str, size_t nStart2, size_t nLen2) const; const wxString& str, size_t nStart2, size_t nLen2) const
{ return Mid(nStart, nLen).Cmp(str.Mid(nStart2, nLen2)); }
// just like strcmp() // just like strcmp()
int compare(const wxChar* sz) const { return Cmp(sz); } int compare(const wxChar* sz) const { return Cmp(sz); }
// substring comparison with first nCount characters of sz // substring comparison with first nCount characters of sz
int compare(size_t nStart, size_t nLen, int compare(size_t nStart, size_t nLen,
const wxChar* sz, size_t nCount = npos) const; const wxChar* sz, size_t nCount = npos) const
{ return Mid(nStart, nLen).Cmp(wxString(sz, nCount)); }
// substring extraction // substring extraction
wxString substr(size_t nStart = 0, size_t nLen = npos) const wxString substr(size_t nStart = 0, size_t nLen = npos) const

View File

@@ -1536,8 +1536,34 @@ int wxString::sprintf(const wxChar *pszFormat, ...)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// standard C++ library string functions // standard C++ library string functions
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
#ifdef wxSTD_STRING_COMPATIBILITY #ifdef wxSTD_STRING_COMPATIBILITY
void wxString::resize(size_t nSize, wxChar ch)
{
size_t len = length();
if ( nSize < len )
{
Truncate(nSize);
}
else if ( nSize > len )
{
*this += wxString(ch, len - nSize);
}
//else: we have exactly the specified length, nothing to do
}
void wxString::swap(wxString& str)
{
// this is slightly less efficient than fiddling with m_pchData directly,
// but it is still quite efficient as we don't copy the string here because
// ref count always stays positive
wxString tmp = str;
str = *this;
*this = str;
}
wxString& wxString::insert(size_t nPos, const wxString& str) wxString& wxString::insert(size_t nPos, const wxString& str)
{ {
wxASSERT( str.GetStringData()->IsValid() ); wxASSERT( str.GetStringData()->IsValid() );