]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxAny::HasSameType()
authorJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 18 Jun 2010 13:30:47 +0000 (13:30 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Fri, 18 Jun 2010 13:30:47 +0000 (13:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64624 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/any.h
interface/wx/any.h
tests/any/anytest.cpp

index 03453ead82f82cdea0b34c04fafdf1885f9e5890..aebc38df55e83ddd7db2f69dcefd63f545f17ffd 100644 (file)
@@ -787,14 +787,24 @@ public:
 
         @remarks You cannot reliably test whether two wxAnys are of
                  same value type by simply comparing return values
-                 of wxAny::GetType(). Instead use
-                 wxAnyValueType::CheckType<T>() template function.
+                 of wxAny::GetType(). Instead, use wxAny::HasSameType().
+
+        @see HasSameType()
     */
     const wxAnyValueType* GetType() const
     {
         return m_type;
     }
 
+    /**
+        Returns @true if this and another wxAny have the same
+        value type.
+    */
+    bool HasSameType(const wxAny& other) const
+    {
+        return GetType()->IsSameType(other.GetType());
+    }
+
     /**
         Tests if wxAny is null (that is, whether there is data).
     */
index 47cc6fb6cd2366c27edf15941fd2088f81bc0f1d..605fb77f3f346b8fa1a1e15219f28b3faf807a42 100644 (file)
@@ -140,12 +140,19 @@ public:
         Returns the value type as wxAnyValueType instance.
 
         @remarks You cannot reliably test whether two wxAnys are of
-                same value type by simply comparing return values
-                of wxAny::GetType(). Instead use
-                wxAnyValueType::CheckType<T>() template function.
+                 same value type by simply comparing return values
+                 of wxAny::GetType(). Instead, use wxAny::HasSameType().
+
+        @see HasSameType()
     */
     const wxAnyValueType* GetType() const;
 
+    /**
+        Returns @true if this and another wxAny have the same
+        value type.
+    */
+    bool HasSameType(const wxAny& other) const;
+
     /**
         Tests if wxAny is null (that is, whether there is data).
     */
index 0d856445a67eb607b747bf9f6dc2fbb167d87cb3..a43b8975cf00caf45da17dbf78e93523a4e80e5a 100644 (file)
@@ -178,6 +178,10 @@ void wxAnyTestCase::CheckType()
     CPPUNIT_ASSERT(wxANY_CHECK_TYPE(m_anyWcharString2, const wchar_t*));
     CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyWcharString2, wxString));
     CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyWcharString2, const char*));
+
+    // HasSameType()
+    CPPUNIT_ASSERT( m_anyWcharString1.HasSameType(m_anyWcharString2) );
+    CPPUNIT_ASSERT( !m_anyWcharString1.HasSameType(m_anyBool1) );
 }
 
 void wxAnyTestCase::Equality()