]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/variant.h
corrected the direction of comparisons between wxString and char/wxChar strings
[wxWidgets.git] / include / wx / variant.h
index 0e3e71f195c2c43a76ecfd553bab27ae2e26001c..61186b5f2002899c87a6b63080bafa254b514ad1 100644 (file)
@@ -20,6 +20,7 @@
 #include "wx/string.h"
 #include "wx/arrstr.h"
 #include "wx/list.h"
+#include "wx/cpp.h"
 
 #if wxUSE_DATETIME
     #include "wx/datetime.h"
@@ -254,14 +255,6 @@ public:
     wxObject* GetWxObjectPtr() const;
 
 
-#if WXWIN_COMPATIBILITY_2_4
-    wxDEPRECATED( wxVariant(const wxStringList& val, const wxString& name = wxEmptyString) );
-    wxDEPRECATED( bool operator== (const wxStringList& value) const );
-    wxDEPRECATED( bool operator!= (const wxStringList& value) const );
-    wxDEPRECATED( void operator= (const wxStringList& value) );
-    wxDEPRECATED( wxStringList& GetStringList() const );
-#endif
-
     // ------------------------------
     // list operations
     // ------------------------------
@@ -316,23 +309,17 @@ private:
     DECLARE_DYNAMIC_CLASS(wxVariant)
 };
 
-/* Fake macro parameter value */
-#ifdef EMPTY_PARAMETER_VALUE
-    #undef EMPTY_PARAMETER_VALUE
-#endif
-#define EMPTY_PARAMETER_VALUE
-
 #define DECLARE_VARIANT_OBJECT(classname) \
-    DECLARE_VARIANT_OBJECT_EXPORTED(classname,EMPTY_PARAMETER_VALUE)
+    DECLARE_VARIANT_OBJECT_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
 
 #define DECLARE_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
-classname& expdecl operator << ( classname &object, const wxVariant &variant ); \
-wxVariant& expdecl operator << ( wxVariant &variant, const classname &object );
+expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
+expdecl wxVariant& operator << ( wxVariant &variant, const classname &object );
 
 #define IMPLEMENT_VARIANT_OBJECT(classname) \
-    IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,EMPTY_PARAMETER_VALUE)
+    IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
 
-#define IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
+#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
 class classname##VariantData: public wxVariantData \
 { \
 public:\
@@ -355,15 +342,6 @@ private: \
 \
 IMPLEMENT_CLASS(classname##VariantData, wxVariantData)\
 \
-bool classname##VariantData::Eq(wxVariantData& data) const \
-{\
-    wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
-\
-    classname##VariantData & otherData = (classname##VariantData &) data;\
-\
-    return (otherData.m_value == m_value);\
-}\
-\
 wxString classname##VariantData::GetType() const\
 {\
     return m_value.GetClassInfo()->GetClassName();\
@@ -374,7 +352,7 @@ wxClassInfo* classname##VariantData::GetValueClassInfo()\
     return m_value.GetClassInfo();\
 }\
 \
-classname& expdecl operator << ( classname &value, const wxVariant &variant )\
+expdecl classname& operator << ( classname &value, const wxVariant &variant )\
 {\
     wxASSERT( wxIsKindOf( variant.GetData(), classname##VariantData ) );\
     \
@@ -383,13 +361,45 @@ classname& expdecl operator << ( classname &value, const wxVariant &variant )\
     return value;\
 }\
 \
-wxVariant& expdecl operator << ( wxVariant &variant, const classname &value )\
+expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
 {\
     classname##VariantData *data = new classname##VariantData( value );\
     variant.SetData( data );\
     return variant;\
 }
 
+// implements a wxVariantData-derived class using for the Eq() method the
+// operator== which must have been provided by "classname"
+#define IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
+IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
+\
+bool classname##VariantData::Eq(wxVariantData& data) const \
+{\
+    wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
+\
+    classname##VariantData & otherData = (classname##VariantData &) data;\
+\
+    return otherData.m_value == m_value;\
+}\
+
+
+// implements a wxVariantData-derived class using for the Eq() method a shallow
+// comparison (through wxObject::IsSameAs function)
+#define IMPLEMENT_VARIANT_OBJECT_SHALLOWCMP(classname) \
+    IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname, wxEMPTY_PARAMETER_VALUE)
+#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \
+IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
+\
+bool classname##VariantData::Eq(wxVariantData& data) const \
+{\
+    wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
+\
+    classname##VariantData & otherData = (classname##VariantData &) data;\
+\
+    return (otherData.m_value.IsSameAs(m_value));\
+}\
+
+
 // Since we want type safety wxVariant we need to fetch and dynamic_cast
 // in a seemingly safe way so the compiler can check, so we define
 // a dynamic_cast /wxDynamicCast analogue.