]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/list.h
wxFrameNameStr was already delivered by #include one line earlier.
[wxWidgets.git] / include / wx / list.h
index b1f5d93a9c5e434cb99560ba16f1fae563302a77..5f0790af7bd959dde15f5bd4cbe4c5cbcd4b398f 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        list.h
+// Name:        wx/list.h
 // Purpose:     wxList, wxStringList classes
 // Author:      Julian Smart
 // Modified by: VZ at 16/11/98: WX_DECLARE_LIST() and typesafe lists added
@@ -143,7 +143,7 @@ private:
         bool m_destroy;                                                       \
     private:                                                                  \
         typedef elT _WX_LIST_ITEM_TYPE_##liT;                                 \
-        static void DeleteFunction( const _WX_LIST_ITEM_TYPE_##liT X );       \
+        static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X );             \
     public:                                                                   \
         class compatibility_iterator                                          \
         {                                                                     \
@@ -166,7 +166,11 @@ private:
             const compatibility_iterator* operator->() const { return this; } \
                                                                               \
             bool operator==(const compatibility_iterator& i) const            \
-                { return (m_list == i.m_list) && (m_iter == i.m_iter); }      \
+            {                                                                 \
+                wxASSERT_MSG( m_list && i.m_list,                             \
+                              _T("comparing invalid iterators is illegal") ); \
+                return (m_list == i.m_list) && (m_iter == i.m_iter);          \
+            }                                                                 \
             bool operator!=(const compatibility_iterator& i) const            \
                 { return !( operator==( i ) ); }                              \
             operator bool() const                                             \
@@ -186,16 +190,16 @@ private:
             }                                                                 \
             compatibility_iterator GetPrevious() const                        \
             {                                                                 \
+                if ( m_iter == m_list->begin() )                              \
+                    return compatibility_iterator();                          \
+                                                                              \
                 iterator i = m_iter;                                          \
                 return compatibility_iterator( m_list, --i );                 \
             }                                                                 \
             int IndexOf() const                                               \
             {                                                                 \
-                return m_list ?                                               \
-                    m_iter != m_list->end() ?                                 \
-                        std::distance( m_list->begin(), m_iter ) :            \
-                            wxNOT_FOUND :                                     \
-                        wxNOT_FOUND;                                          \
+                return *this ? std::distance( m_list->begin(), m_iter )       \
+                             : wxNOT_FOUND;                                   \
             }                                                                 \
         };                                                                    \
     public:                                                                   \
@@ -309,7 +313,7 @@ private:
     WX_DECLARE_USER_EXPORTED_LIST(elementtype, listname, usergoo)
 
 // this macro must be inserted in your program after
-//      #include <wx/listimpl.cpp>
+//      #include "wx/listimpl.cpp"
 #define WX_DEFINE_LIST(name)    "don't forget to include listimpl.cpp!"
 
 #define WX_DEFINE_EXPORTED_LIST(name)      WX_DEFINE_LIST(name)
@@ -676,7 +680,17 @@ private:
     {                                                                       \
     public:                                                                 \
         typedef nodetype Node;                                              \
-        typedef Node* compatibility_iterator;                               \
+        class compatibility_iterator                                        \
+        {                                                                   \
+        public:                                                             \
+            compatibility_iterator(Node *ptr = NULL) : m_ptr(ptr) { }       \
+                                                                            \
+            Node *operator->() const { return m_ptr; }                      \
+            operator Node *() const { return m_ptr; }                       \
+                                                                            \
+        private:                                                            \
+            Node *m_ptr;                                                    \
+        };                                                                  \
                                                                             \
         name(wxKeyType keyType = wxKEY_NONE) : wxListBase(keyType)          \
             { }                                                             \
@@ -688,12 +702,12 @@ private:
         name& operator=(const name& list)                                   \
             { Assign(list); return *this; }                                 \
                                                                             \
-        nodetype *GetFirst() const                                          \
+        compatibility_iterator GetFirst() const                             \
             { return (nodetype *)wxListBase::GetFirst(); }                  \
-        nodetype *GetLast() const                                           \
+        compatibility_iterator GetLast() const                              \
             { return (nodetype *)wxListBase::GetLast(); }                   \
                                                                             \
-        nodetype *Item(size_t index) const                                  \
+        compatibility_iterator Item(size_t index) const                     \
             { return (nodetype *)wxListBase::Item(index); }                 \
                                                                             \
         T *operator[](size_t index) const                                   \
@@ -702,18 +716,18 @@ private:
             return node ? (T*)(node->GetData()) : (T*)NULL;                 \
         }                                                                   \
                                                                             \
-        nodetype *Append(Tbase *object)                                     \
+        compatibility_iterator Append(Tbase *object)                        \
             { return (nodetype *)wxListBase::Append(object); }              \
-        nodetype *Insert(Tbase *object)                                     \
+        compatibility_iterator Insert(Tbase *object)                        \
             { return (nodetype *)Insert((nodetype*)NULL, object); }         \
-        nodetype *Insert(size_t pos, Tbase *object)                         \
+        compatibility_iterator Insert(size_t pos, Tbase *object)            \
             { return (nodetype *)wxListBase::Insert(pos, object); }         \
-        nodetype *Insert(nodetype *prev, Tbase *object)                     \
+        compatibility_iterator Insert(nodetype *prev, Tbase *object)        \
             { return (nodetype *)wxListBase::Insert(prev, object); }        \
                                                                             \
-        nodetype *Append(long key, void *object)                            \
+        compatibility_iterator Append(long key, void *object)               \
             { return (nodetype *)wxListBase::Append(key, object); }         \
-        nodetype *Append(const wxChar *key, void *object)                   \
+        compatibility_iterator Append(const wxChar *key, void *object)      \
             { return (nodetype *)wxListBase::Append(key, object); }         \
                                                                             \
         nodetype *DetachNode(nodetype *node)                                \
@@ -725,7 +739,7 @@ private:
         void Erase(compatibility_iterator it)                               \
             { DeleteNode(it); }                                             \
                                                                             \
-        nodetype *Find(const Tbase *object) const                           \
+        compatibility_iterator Find(const Tbase *object) const              \
             { return (nodetype *)wxListBase::Find(object); }                \
                                                                             \
         virtual nodetype *Find(const wxListKey& key) const                  \
@@ -1064,7 +1078,7 @@ private:
     WX_DECLARE_LIST_PTR_2(elementtype, listname, wx##listname##Node, class usergoo)
 
 // this macro must be inserted in your program after
-//      #include <wx/listimpl.cpp>
+//      #include "wx/listimpl.cpp"
 #define WX_DEFINE_LIST(name)    "don't forget to include listimpl.cpp!"
 
 #define WX_DEFINE_EXPORTED_LIST(name)      WX_DEFINE_LIST(name)
@@ -1236,5 +1250,4 @@ public:
         (list).clear();                                                      \
     }
 
-#endif
-    // _WX_LISTH__
+#endif // _WX_LISTH__