]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Fixes for VC++ 4 compilation; fixed wxCommandEvent arg in grid.h;
[wxWidgets.git] / src / common / string.cpp
index 4a667a59cc4fab8883dca6432edb1ebd83218dba..32350af0338afc6f93302ecfb572c208201eea2f 100644 (file)
@@ -176,6 +176,12 @@ istream& operator>>(istream& is, wxString& WXUNUSED(str))
   return is;
 }
 
+ostream& operator<<(ostream& os, const wxString& str)
+{
+  os << str.c_str();
+  return os;
+}
+
 #endif  //std::string compatibility
 
 // ----------------------------------------------------------------------------
@@ -1844,7 +1850,7 @@ int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
 }
 
 // add item at the end
-void wxArrayString::Add(const wxString& str)
+size_t wxArrayString::Add(const wxString& str)
 {
   if ( m_autoSort ) {
     // insert the string at the correct position to keep the array sorted
@@ -1869,6 +1875,8 @@ void wxArrayString::Add(const wxString& str)
     wxASSERT_MSG( lo == hi, wxT("binary search broken") );
 
     Insert(str, lo);
+
+    return (size_t)lo;
   }
   else {
     wxASSERT( str.GetStringData()->IsValid() );
@@ -1879,7 +1887,9 @@ void wxArrayString::Add(const wxString& str)
     str.GetStringData()->Lock();
 
     // just append
-    m_pItems[m_nCount++] = (wxChar *)str.c_str();
+    m_pItems[m_nCount] = (wxChar *)str.c_str(); // const_cast
+
+    return m_nCount++;
   }
 }
 
@@ -1888,8 +1898,6 @@ void wxArrayString::Insert(const wxString& str, size_t nIndex)
 {
   wxASSERT( str.GetStringData()->IsValid() );
 
-  wxCHECK_RET( !m_autoSort, wxT("can't use this method with sorted arrays") );
-
   wxCHECK_RET( nIndex <= m_nCount, wxT("bad index in wxArrayString::Insert") );
 
   Grow();