return FALSE;
}
+/*
+ * wxVariantDataWxObjectPtr
+ */
+
+class wxVariantDataWxObjectPtr: public wxVariantData
+{
+DECLARE_DYNAMIC_CLASS(wxVariantDataWxObjectPtr)
+public:
+ wxVariantDataWxObjectPtr() { }
+ wxVariantDataWxObjectPtr(wxObject* value) { m_value = value; }
+
+ inline wxObject* GetValue() const { return m_value; }
+ inline void SetValue(wxObject* value) { m_value = value; }
+
+ virtual void Copy(wxVariantData& data);
+ virtual bool Eq(wxVariantData& data) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Write(wxSTD ostream& str) const;
+#endif
+ virtual bool Write(wxString& str) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Read(wxSTD istream& str);
+#endif
+ virtual bool Read(wxString& str);
+ virtual wxString GetType() const ;
+ virtual wxVariantData* Clone() { return new wxVariantDataWxObjectPtr; }
+
+ virtual wxClassInfo* GetValueClassInfo() ;
+protected:
+ wxObject* m_value;
+
+ DECLARE_NO_COPY_CLASS(wxVariantDataWxObjectPtr)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariantDataWxObjectPtr, wxVariantData)
+
+void wxVariantDataWxObjectPtr::Copy(wxVariantData& data)
+{
+ wxASSERT_MSG( wxIsKindOf((&data), wxVariantDataWxObjectPtr) ,\
+ wxT("wxVariantDataWxObjectPtr::Copy: Can't copy to this type of data") \
+ );
+
+ wxVariantDataWxObjectPtr& otherData = (wxVariantDataWxObjectPtr&) data;
+
+ otherData.m_value = m_value;
+}
+
+bool wxVariantDataWxObjectPtr::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( wxIsKindOf((&data), wxVariantDataWxObjectPtr), wxT("wxVariantDataWxObjectPtr::Eq: argument mismatch") );
+
+ wxVariantDataWxObjectPtr& otherData = (wxVariantDataWxObjectPtr&) data;
+
+ return (otherData.m_value == m_value);
+}
+
+wxString wxVariantDataWxObjectPtr::GetType() const
+{
+ wxString returnVal(wxT("wxObject"));
+ if (m_value) {
+ returnVal = m_value->GetClassInfo()->GetClassName();
+ }
+ return returnVal;
+}
+
+wxClassInfo* wxVariantDataWxObjectPtr::GetValueClassInfo()
+{
+ wxClassInfo* returnVal=NULL;
+
+ if (m_value) returnVal = m_value->GetClassInfo();
+
+ return returnVal;
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataWxObjectPtr::Write(wxSTD ostream& str) const
+{
+ wxString s;
+ Write(s);
+ str << (const char*) s.mb_str();
+ return TRUE;
+}
+#endif
+
+bool wxVariantDataWxObjectPtr::Write(wxString& str) const
+{
+ str.Printf(wxT("%s(%ld)"), GetType().c_str(), (long) m_value);
+ return TRUE;
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataWxObjectPtr::Read(wxSTD istream& WXUNUSED(str))
+{
+ // Not implemented
+ return FALSE;
+}
+#endif
+
+bool wxVariantDataWxObjectPtr::Read(wxString& WXUNUSED(str))
+{
+ // Not implemented
+ return FALSE;
+}
+
+
/*
* wxVariantDataDateTime
*/
m_name = name;
}
+wxVariant::wxVariant( wxObject* val, const wxString& name)
+{
+ m_data = new wxVariantDataWxObjectPtr(val);
+ m_name = name;
+}
+
+#if wxUSE_DATETIME
+wxVariant::wxVariant(const wxDateTime& val, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDateTime(val);
+ m_name = name;
+}
+#endif // wxUSE_DATETIME
+
#if wxUSE_ODBC
wxVariant::wxVariant(const TIME_STRUCT* valptr, const wxString& name) // Date
{
return (GetType() == type);
}
+bool wxVariant::IsValueKindOf(const wxClassInfo* type) const
+{
+ wxClassInfo* info=m_data->GetValueClassInfo();
+ return info ? info->IsKindOf(type) : false ;
+}
+
// Value accessors
double wxVariant::GetReal() const
return (void*) ((wxVariantDataVoidPtr*) m_data)->GetValue();
}
+wxObject* wxVariant::GetWxObjectPtr()
+{
+ wxASSERT(wxIsKindOf(m_data, wxVariantDataWxObjectPtr));
+ return (wxObject*) ((wxVariantDataWxObjectPtr*) m_data)->GetValue();
+}
+
#if wxUSE_DATETIME
wxDateTime wxVariant::GetDateTime() const
{