]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/variant.cpp
Gracefully disconnect clients in wxDDEServer dtor.
[wxWidgets.git] / src / common / variant.cpp
index 57aba64bb1d84925d12e6a109239292675359905..f5a417ce37ab02cb9f7b04d8c296d6d5376f8ab7 100644 (file)
@@ -206,6 +206,10 @@ wxAnyToVariantRegistration::
     wxPreRegisterAnyToVariant(this);
 }
 
+wxAnyToVariantRegistration::~wxAnyToVariantRegistration()
+{
+}
+
 wxVariant::wxVariant(const wxAny& any)
     : wxObject()
 {
@@ -221,11 +225,10 @@ wxVariant::wxVariant(const wxAny& any)
 
 wxAny wxVariant::GetAny() const
 {
-    wxAny any;
-
     if ( IsNull() )
-        return any;
+        return wxAny();
 
+    wxAny any;
     wxVariantData* data = GetData();
 
     if ( data->GetAsAny(&any) )
@@ -267,18 +270,20 @@ public:
 
     virtual wxString GetType() const { return wxT("long"); }
 
+#if wxUSE_ANY
     // Since wxAny does not have separate type for integers shorter than
     // longlong, we do not usually implement wxVariant->wxAny conversion
     // here (but in wxVariantDataLongLong instead).
-#ifndef wxLongLong_t
+  #ifndef wxLongLong_t
     DECLARE_WXANY_CONVERSION()
-#else
+  #else
     bool GetAsAny(wxAny* any) const
     {
         *any = m_value;
         return true;
     }
-#endif
+  #endif
+#endif // wxUSE_ANY
 
 protected:
     long m_value;
@@ -876,6 +881,26 @@ protected:
 
 IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxString, wxVariantDataString)
 
+#if wxUSE_ANY
+// This allows converting string literal wxAnys to string variants
+wxVariantData* wxVariantDataFromConstCharPAny(const wxAny& any)
+{
+    return new wxVariantDataString(wxANY_AS(any, const char*));
+}
+
+wxVariantData* wxVariantDataFromConstWchar_tPAny(const wxAny& any)
+{
+    return new wxVariantDataString(wxANY_AS(any, const wchar_t*));
+}
+
+_REGISTER_WXANY_CONVERSION(const char*,
+                           ConstCharP,
+                           wxVariantDataFromConstCharPAny)
+_REGISTER_WXANY_CONVERSION(const wchar_t*,
+                           ConstWchar_tP,
+                           wxVariantDataFromConstWchar_tPAny)
+#endif
+
 bool wxVariantDataString::Eq(wxVariantData& data) const
 {
     wxASSERT_MSG( (data.GetType() == wxT("string")), wxT("wxVariantDataString::Eq: argument mismatch") );