]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
Don't include dlfcn.h from wx/dynlib.h on Darwin. We might be using our own
[wxWidgets.git] / include / wx / string.h
index 2e7b6ca1b671ca5655cd3aabba2ffff00f17c6ec..deecb1795bf7193f172beb2f33bd1c772fd657c6 100644 (file)
@@ -657,7 +657,14 @@ public:
       iterator(const iterator& i)
           : m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
       iterator& operator=(const iterator& i)
-        { m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
+      {
+          if (&i != this)
+          {
+              m_cur = i.m_cur;
+              m_node.set(i.str(), &m_cur);
+          }
+          return *this;
+      }
 
       reference operator*()
         { return wxUniCharRef::CreateForString(m_node, m_cur); }
@@ -692,7 +699,14 @@ public:
           : m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
 
       const_iterator& operator=(const const_iterator& i)
-        { m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
+      {
+          if (&i != this)
+          {
+              m_cur = i.m_cur;
+              m_node.set(i.str(), &m_cur);
+          }
+          return *this;
+      }
       const_iterator& operator=(const iterator& i)
         { m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
 
@@ -1324,12 +1338,20 @@ public:
   // overloaded assignment
     // from another wxString
   wxString& operator=(const wxString& stringSrc)
-    { m_impl = stringSrc.m_impl; return *this; }
+    { if (&stringSrc != this) m_impl = stringSrc.m_impl; return *this; }
   wxString& operator=(const wxCStrData& cstr)
     { return *this = cstr.AsString(); }
     // from a character
   wxString& operator=(wxUniChar ch)
-    { m_impl = wxStringOperations::EncodeChar(ch); return *this; }
+  {
+#if wxUSE_UNICODE_UTF8
+    if ( !ch.IsAscii() )
+        m_impl = wxStringOperations::EncodeChar(ch);
+    else
+#endif
+        m_impl = (wxStringCharType)ch;
+    return *this;
+  }
   wxString& operator=(wxUniCharRef ch)
     { return operator=((wxUniChar)ch); }
   wxString& operator=(char ch)
@@ -2228,8 +2250,15 @@ public:
     // find the first occurence of character ch after nStart
   size_t find(wxUniChar ch, size_t nStart = 0) const
   {
-    return PosFromImpl(m_impl.find(wxStringOperations::EncodeChar(ch),
-                                   PosToImpl(nStart)));
+#if wxUSE_UNICODE_UTF8
+    if ( !ch.IsAscii() )
+        return PosFromImpl(m_impl.find(wxStringOperations::EncodeChar(ch),
+                                       PosToImpl(nStart)));
+    else
+#endif
+        return PosFromImpl(m_impl.find((wxStringCharType)ch,
+                                       PosToImpl(nStart)));
+
   }
   size_t find(wxUniCharRef ch, size_t nStart = 0) const
     {  return find(wxUniChar(ch), nStart); }
@@ -2266,8 +2295,14 @@ public:
     // as find, but from the end
   size_t rfind(wxUniChar ch, size_t nStart = npos) const
   {
-    return PosFromImpl(m_impl.rfind(wxStringOperations::EncodeChar(ch),
-                                    PosToImpl(nStart)));
+#if wxUSE_UNICODE_UTF8
+    if ( !ch.IsAscii() )
+        return PosFromImpl(m_impl.rfind(wxStringOperations::EncodeChar(ch),
+                                        PosToImpl(nStart)));
+    else
+#endif
+        return PosFromImpl(m_impl.rfind((wxStringCharType)ch,
+                                        PosToImpl(nStart)));
   }
   size_t rfind(wxUniCharRef ch, size_t nStart = npos) const
     {  return rfind(wxUniChar(ch), nStart); }
@@ -2505,7 +2540,15 @@ public:
     { return operator+=(s.data()); }
       // string += char
   wxString& operator+=(wxUniChar ch)
-    { m_impl += wxStringOperations::EncodeChar(ch); return *this; }
+  {
+#if wxUSE_UNICODE_UTF8
+    if ( !ch.IsAscii() )
+        m_impl += wxStringOperations::EncodeChar(ch);
+    else
+#endif
+        m_impl += (wxStringCharType)ch;
+    return *this;
+  }
   wxString& operator+=(wxUniCharRef ch) { return *this += wxUniChar(ch); }
   wxString& operator+=(int ch) { return *this += wxUniChar(ch); }
   wxString& operator+=(char ch) { return *this += wxUniChar(ch); }