]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
compilation fix for #ifdef __WXDEBUG__
[wxWidgets.git] / src / common / string.cpp
index 9f97667da3d72099ccdb084c6d7ab7e7b33bd2cf..7fe2592efb518ff128036fbf22e086a1ebbb253e 100644 (file)
@@ -79,7 +79,7 @@ static const struct
 } g_strEmpty = { {-1, 0, 0}, wxT('\0') };
 
 // empty C style string: points to 'string data' byte of g_strEmpty
-extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy;
+extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy;
 
 // ----------------------------------------------------------------------------
 // global functions
@@ -958,8 +958,13 @@ wxString wxString::AfterFirst(wxChar ch) const
 }
 
 // replace first (or all) occurences of some substring with another one
-size_t wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll)
+size_t
+wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll)
 {
+    // if we tried to replace an empty string we'd enter an infinite loop below
+    wxCHECK_MSG( szOld && *szOld && szNew, 0,
+                 _T("wxString::Replace(): invalid parameter") );
+
   size_t uiCount = 0;   // count of replacements made
 
   size_t uiOldLen = wxStrlen(szOld);
@@ -1901,6 +1906,8 @@ void wxArrayString::Shrink()
   }
 }
 
+#if WXWIN_COMPATIBILITY_2_4
+
 // return a wxString[] as required for some control ctors.
 wxString* wxArrayString::GetStringArray() const
 {
@@ -1916,6 +1923,8 @@ wxString* wxArrayString::GetStringArray() const
     return array;
 }
 
+#endif // WXWIN_COMPATIBILITY_2_4
+
 // searches the array for an item (forward or backwards)
 int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
 {
@@ -2046,7 +2055,7 @@ void wxArrayString::SetCount(size_t count)
 }
 
 // removes item from array (by index)
-void wxArrayString::Remove(size_t nIndex, size_t nRemove)
+void wxArrayString::RemoveAt(size_t nIndex, size_t nRemove)
 {
   wxCHECK_RET( nIndex < m_nCount, wxT("bad index in wxArrayString::Remove") );
   wxCHECK_RET( nIndex + nRemove <= m_nCount,
@@ -2069,7 +2078,7 @@ void wxArrayString::Remove(const wxChar *sz)
   wxCHECK_RET( iIndex != wxNOT_FOUND,
                wxT("removing inexistent element in wxArrayString::Remove") );
 
-  Remove(iIndex);
+  RemoveAt(iIndex);
 }
 
 // ----------------------------------------------------------------------------
@@ -2137,16 +2146,16 @@ void wxArrayString::Sort(CompareFunction compareFunction)
   END_SORT();
 }
 
-void wxArrayString::Sort(bool reverseOrder)
-{
-  START_SORT();
-
-  wxASSERT( !gs_compareFunction );  // must have been reset to NULL
-  gs_sortAscending = !reverseOrder;
+typedef  int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, const void *second);
 
-  DoSort();
+void wxArrayString::Sort(CompareFunction2 compareFunction)
+{
+  qsort(m_pItems, m_nCount, sizeof(wxChar *), (wxStringCompareFn)compareFunction);
+}
 
-  END_SORT();
+void wxArrayString::Sort(bool reverseOrder)
+{
+  Sort(reverseOrder ? wxStringSortDescending : wxStringSortAscending);
 }
 
 void wxArrayString::DoSort()
@@ -2172,3 +2181,12 @@ bool wxArrayString::operator==(const wxArrayString& a) const
     return TRUE;
 }
 
+int wxStringSortAscending(wxString* s1, wxString* s2)
+{
+    return wxStrcmp(s1->c_str(), s2->c_str());
+}
+
+int wxStringSortDescending(wxString* s1, wxString* s2)
+{
+    return -wxStrcmp(s1->c_str(), s2->c_str());
+}