]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
CanAcceptFocus() now returns true if either the window itself or one of its children...
[wxWidgets.git] / include / wx / string.h
index 86eb7eef964259bcf1b668be6280c4966910c23e..7cccebcad3b9ef04c1002ef088fbb8a79022d4b8 100644 (file)
@@ -390,6 +390,10 @@ struct WXDLLIMPEXP_BASE wxStringIteratorNode
     wxStringImpl::const_iterator *m_citer;
     wxStringImpl::iterator *m_iter;
     wxStringIteratorNode *m_prev, *m_next;
+
+    // the node belongs to a particular iterator instance, it's not copied
+    // when a copy of the iterator is made
+    DECLARE_NO_COPY_CLASS(wxStringIteratorNode)
 };
 #endif // wxUSE_UNICODE_UTF8
 
@@ -639,7 +643,7 @@ public:
       private:                                                              \
           underlying_iterator m_cur
 
-  class const_iterator;
+  class WXDLLIMPEXP_BASE const_iterator;
 
 #if wxUSE_UNICODE_UTF8
   // NB: In UTF-8 build, (non-const) iterator needs to keep reference
@@ -656,13 +660,15 @@ public:
   //     string and traversing it in wxUniCharRef::operator=(). Head of the
   //     list is stored in wxString. (FIXME-UTF8)
 
-  class iterator
+  class WXDLLIMPEXP_BASE iterator
   {
       WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef);
 
   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; return *this; }
 
       reference operator*()
         { return wxUniCharRef::CreateForString(m_node, m_cur); }
@@ -687,7 +693,7 @@ public:
       friend class const_iterator;
   };
 
-  class const_iterator
+  class WXDLLIMPEXP_BASE const_iterator
   {
       // NB: reference_type is intentionally value, not reference, the character
       //     may be encoded differently in wxString data:
@@ -699,6 +705,11 @@ public:
       const_iterator(const iterator& i)
           : m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
 
+      const_iterator& operator=(const const_iterator& i)
+        { m_cur = i.m_cur; return *this; }
+      const_iterator& operator=(const iterator& i)
+        { m_cur = i.m_cur; return *this; }
+
       reference operator*() const
         { return wxStringOperations::DecodeChar(m_cur); }
 
@@ -726,7 +737,7 @@ public:
 
 #else // !wxUSE_UNICODE_UTF8
 
-  class iterator
+  class WXDLLIMPEXP_BASE iterator
   {
       WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef);
 
@@ -753,7 +764,7 @@ public:
       friend class const_iterator;
   };
 
-  class const_iterator
+  class WXDLLIMPEXP_BASE const_iterator
   {
       // NB: reference_type is intentionally value, not reference, the character
       //     may be encoded differently in wxString data:
@@ -992,7 +1003,12 @@ public:
     wxString(const std::string& str)
         { assign(str.c_str(), str.length()); }
   #endif
+#endif // wxUSE_STD_STRING
 
+  // Unlike ctor from std::string, we provide conversion to std::string only
+  // if wxUSE_STL and not merely wxUSE_STD_STRING (which is on by default),
+  // because it conflicts with operator const char/wchar_t*:
+#if wxUSE_STL
   #if wxUSE_UNICODE_WCHAR && wxUSE_STL_BASED_WXSTRING
     // wxStringImpl is std::string in the encoding we want
     operator const wxStdWideString&() const { return m_impl; }
@@ -1165,8 +1181,13 @@ public:
 
     // implicit conversion to C string
     operator wxCStrData() const { return c_str(); }
+
+    // these operators conflict with operators for conversion to std::string,
+    // so they must be disabled in STL build:
+#if !wxUSE_STL
     operator const char*() const { return c_str(); }
     operator const wchar_t*() const { return c_str(); }
+#endif
 
     // implicit conversion to untyped pointer for compatibility with previous
     // wxWidgets versions: this is the same as conversion to const char * so it
@@ -1207,11 +1228,19 @@ public:
 #if wxUSE_UNICODE_UTF8
     static wxString FromUTF8(const char *utf8)
     {
+      if ( !utf8 )
+          return wxEmptyString;
+
       wxASSERT( wxStringOperations::IsValidUtf8String(utf8) );
       return FromImpl(wxStringImpl(utf8));
     }
     static wxString FromUTF8(const char *utf8, size_t len)
     {
+      if ( !utf8 )
+          return wxEmptyString;
+      if ( len == npos )
+          return FromUTF8(utf8);
+
       wxASSERT( wxStringOperations::IsValidUtf8String(utf8, len) );
       return FromImpl(wxStringImpl(utf8, len));
     }
@@ -2520,6 +2549,12 @@ private:
 private:
   wxStringImpl m_impl;
 
+#ifdef __VISUALC__
+    // "struct 'ConvertedBuffer<T>' needs to have dll-interface to be used by
+    // clients of class 'wxString'" - this is private, we don't care
+    #pragma warning (disable:4251)
+#endif
+
   // buffers for compatibility conversion from (char*)c_str() and
   // (wchar_t*)c_str():
   // FIXME-UTF8: bechmark various approaches to keeping compatibility buffers
@@ -2548,6 +2583,10 @@ private:
   ConvertedBuffer<wchar_t> m_convertedToWChar;
 #endif
 
+#ifdef __VISUALC__
+    #pragma warning (default:4251)
+#endif
+
 #if wxUSE_UNICODE_UTF8
   // FIXME-UTF8: (try to) move this elsewhere (TLS) or solve differently
   //             assigning to character pointer to by wxString::interator may
@@ -2557,6 +2596,10 @@ private:
   {
       wxStringIteratorNodeHead() : ptr(NULL) {}
       wxStringIteratorNode *ptr;
+
+      // copying is disallowed as it would result in more than one pointer into
+      // the same linked list
+      DECLARE_NO_COPY_CLASS(wxStringIteratorNodeHead)
   };
 
   wxStringIteratorNodeHead m_iterators;