]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/hashmap.h
fix warnings in EventsSuppressor ctor from gcc with -O option
[wxWidgets.git] / include / wx / hashmap.h
index b6ff1455e2ddaec6ab3bdc9da6188447a92685d7..47d583b840b84de620cb42ef911f38d0dee8c393 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        hashmap.h
+// Name:        wx/hashmap.h
 // Purpose:     wxHashMap class
 // Author:      Mattia Barbon
 // Modified by:
 // Purpose:     wxHashMap class
 // Author:      Mattia Barbon
 // Modified by:
@@ -13,6 +13,7 @@
 #define _WX_HASHMAP_H_
 
 #include "wx/string.h"
 #define _WX_HASHMAP_H_
 
 #include "wx/string.h"
+#include "wx/wxcrt.h"
 
 #if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
     && (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP))
 
 #if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
     && (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP))
@@ -143,8 +144,6 @@ public: \
         value_type m_value; \
     }; \
  \
         value_type m_value; \
     }; \
  \
-    CLASSEXP Iterator; \
-    friend CLASSEXP Iterator; \
 protected: \
     static void DeleteNode( _wxHashTable_NodeBase* node ) \
     { \
 protected: \
     static void DeleteNode( _wxHashTable_NodeBase* node ) \
     { \
@@ -185,6 +184,7 @@ public: \
             m_node = next ? next : GetNextNode(); \
         } \
     }; \
             m_node = next ? next : GetNextNode(); \
         } \
     }; \
+    friend class Iterator; \
  \
 public: \
     CLASSEXP iterator : public Iterator \
  \
 public: \
     CLASSEXP iterator : public Iterator \
@@ -271,9 +271,9 @@ public: \
     const_iterator end() const { return const_iterator( 0, this ); } \
     iterator end() { return iterator( 0, this ); } \
     const_iterator begin() const \
     const_iterator end() const { return const_iterator( 0, this ); } \
     iterator end() { return iterator( 0, this ); } \
     const_iterator begin() const \
-        { return const_iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); }; \
+        { return const_iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); }  \
     iterator begin() \
     iterator begin() \
-        { return iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); }; \
+        { return iterator( (Node*)GetFirstNode( m_tableBuckets, (_wxHashTable_NodeBase**)m_table ), this ); }  \
  \
     size_type erase( const const_key_type& key ) \
     { \
  \
     size_type erase( const const_key_type& key ) \
     { \
@@ -465,11 +465,19 @@ class WXDLLIMPEXP_BASE wxIntegerHash
     WX_HASH_MAP_NAMESPACE::hash<unsigned short> ushortHash;
 
 #if defined wxLongLong_t && !defined wxLongLongIsLong
     WX_HASH_MAP_NAMESPACE::hash<unsigned short> ushortHash;
 
 #if defined wxLongLong_t && !defined wxLongLongIsLong
+    // hash<wxLongLong_t> ought to work but doesn't on some compilers
+    #if (!defined SIZEOF_LONG_LONG && SIZEOF_LONG == 4) \
+        || (defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG * 2)
     size_t longlongHash( wxLongLong_t x ) const
     {
         return longHash( wx_truncate_cast(long, x) ) ^
                longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) );
     }
     size_t longlongHash( wxLongLong_t x ) const
     {
         return longHash( wx_truncate_cast(long, x) ) ^
                longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) );
     }
+    #elif defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG
+    WX_HASH_MAP_NAMESPACE::hash<long> longlongHash;
+    #else
+    WX_HASH_MAP_NAMESPACE::hash<wxLongLong_t> longlongHash;
+    #endif
 #endif
 
 public:
 #endif
 
 public:
@@ -553,21 +561,29 @@ public:
     wxPointerEqual& operator=(const wxPointerEqual&) { return *this; }
 };
 
     wxPointerEqual& operator=(const wxPointerEqual&) { return *this; }
 };
 
-// wxString, char*, wxChar*
+// wxString, char*, wchar_t*
 class WXDLLIMPEXP_BASE wxStringHash
 {
 public:
     wxStringHash() {}
     unsigned long operator()( const wxString& x ) const
 class WXDLLIMPEXP_BASE wxStringHash
 {
 public:
     wxStringHash() {}
     unsigned long operator()( const wxString& x ) const
-        { return wxCharStringHash( x.c_str() ); }
-    unsigned long operator()( const wxChar* x ) const
-        { return wxCharStringHash( x ); }
-    static unsigned long wxCharStringHash( const wxChar* );
-#if wxUSE_UNICODE
+        { return stringHash( x.wx_str() ); }
+    unsigned long operator()( const wchar_t* x ) const
+        { return stringHash( x ); }
     unsigned long operator()( const char* x ) const
     unsigned long operator()( const char* x ) const
-        { return charStringHash( x ); }
-    static unsigned long charStringHash( const char* );
-#endif // wxUSE_UNICODE
+        { return stringHash( x ); }
+
+#if WXWIN_COMPATIBILITY_2_8
+    static unsigned long wxCharStringHash( const wxChar* x )
+        { return stringHash(x); }
+    #if wxUSE_UNICODE
+    static unsigned long charStringHash( const char* x )
+        { return stringHash(x); }
+    #endif
+#endif // WXWIN_COMPATIBILITY_2_8
+
+    static unsigned long stringHash( const wchar_t* );
+    static unsigned long stringHash( const char* );
 
     wxStringHash& operator=(const wxStringHash&) { return *this; }
 };
 
     wxStringHash& operator=(const wxStringHash&) { return *this; }
 };
@@ -708,4 +724,3 @@ WX_DECLARE_HASH_MAP_WITH_DECL( long, long, wxIntegerHash, wxIntegerEqual,
 
 
 #endif // _WX_HASHMAP_H_
 
 
 #endif // _WX_HASHMAP_H_
-