]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/variant.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / variant.h
index 2f54c1b40455eb29a40ba2875e229782c736b437..39adc729b905beea97990744913d1235ed697f47 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Julian Smart
 // Modified by:
 // Created:     10/09/98
-// RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -230,6 +229,26 @@ public:
     inline operator wxString () const {  return MakeString(); }
     wxString GetString() const;
 
+#if wxUSE_STD_STRING
+    wxVariant(const std::string& val, const wxString& name = wxEmptyString);
+    bool operator==(const std::string& value) const
+        { return operator==(wxString(value)); }
+    bool operator!=(const std::string& value) const
+        { return operator!=(wxString(value)); }
+    wxVariant& operator=(const std::string& value)
+        { return operator=(wxString(value)); }
+    operator std::string() const { return (operator wxString()).ToStdString(); }
+
+    wxVariant(const wxStdWideString& val, const wxString& name = wxEmptyString);
+    bool operator==(const wxStdWideString& value) const
+        { return operator==(wxString(value)); }
+    bool operator!=(const wxStdWideString& value) const
+        { return operator!=(wxString(value)); }
+    wxVariant& operator=(const wxStdWideString& value)
+        { return operator=(wxString(value)); }
+    operator wxStdWideString() const { return (operator wxString()).ToStdWstring(); }
+#endif // wxUSE_STD_STRING
+
     // wxUniChar
     wxVariant(const wxUniChar& val, const wxString& name = wxEmptyString);
     wxVariant(const wxUniCharRef& val, const wxString& name = wxEmptyString);
@@ -342,6 +361,24 @@ public:
 #if wxUSE_LONGLONG
     bool Convert(wxLongLong* value) const;
     bool Convert(wxULongLong* value) const;
+  #ifdef wxLongLong_t
+    bool Convert(wxLongLong_t* value) const
+    {
+        wxLongLong temp;
+        if ( !Convert(&temp) )
+            return false;
+        *value = temp.GetValue();
+        return true;
+    }
+    bool Convert(wxULongLong_t* value) const
+    {
+        wxULongLong temp;
+        if ( !Convert(&temp) )
+            return false;
+        *value = temp.GetValue();
+        return true;
+    }
+  #endif // wxLongLong_t
 #endif // wxUSE_LONGLONG
 
 // Attributes
@@ -376,6 +413,7 @@ class WXDLLIMPEXP_BASE wxAnyToVariantRegistration
 {
 public:
     wxAnyToVariantRegistration(wxVariantDataFactory factory);
+    virtual ~wxAnyToVariantRegistration();
 
     virtual wxAnyValueType* GetAssociatedType() = 0;
     wxVariantDataFactory GetFactory() const { return m_factory; }
@@ -403,10 +441,13 @@ private:
 virtual bool GetAsAny(wxAny* any) const; \
 static wxVariantData* VariantDataFactory(const wxAny& any);
 
-#define REGISTER_WXANY_CONVERSION(T, CLASSNAME) \
+#define _REGISTER_WXANY_CONVERSION(T, CLASSNAME, FUNC) \
 static wxAnyToVariantRegistrationImpl<T> \
     gs_##CLASSNAME##AnyToVariantRegistration = \
-    wxAnyToVariantRegistrationImpl<T>(&CLASSNAME::VariantDataFactory);
+    wxAnyToVariantRegistrationImpl<T>(&FUNC);
+
+#define REGISTER_WXANY_CONVERSION(T, CLASSNAME) \
+_REGISTER_WXANY_CONVERSION(T, CLASSNAME, CLASSNAME::VariantDataFactory)
 
 #define IMPLEMENT_TRIVIAL_WXANY_CONVERSION(T, CLASSNAME) \
 bool CLASSNAME::GetAsAny(wxAny* any) const \
@@ -420,9 +461,6 @@ wxVariantData* CLASSNAME::VariantDataFactory(const wxAny& any) \
 } \
 REGISTER_WXANY_CONVERSION(T, CLASSNAME)
 
-// This is needed for wxVariantList conversion
-WX_DECLARE_LIST_WITH_DECL(wxAny, wxAnyList, class WXDLLIMPEXP_BASE);
-
 #else // if !wxUSE_ANY
 
 #define DECLARE_WXANY_CONVERSION()
@@ -531,7 +569,11 @@ bool classname##VariantData::Eq(wxVariantData& data) const \
                   var.GetWxObjectPtr() : NULL));
 
 // Replacement for using wxDynamicCast on a wxVariantData object
-#define wxDynamicCastVariantData(data, classname) dynamic_cast<classname*>(data)
+#ifndef wxNO_RTTI
+    #define wxDynamicCastVariantData(data, classname) dynamic_cast<classname*>(data)
+#endif
+
+#define wxStaticCastVariantData(data, classname) static_cast<classname*>(data)
 
 extern wxVariant WXDLLIMPEXP_BASE wxNullVariant;