1998-09-12 17:31:48 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-03-12 14:49:25 +00:00
|
|
|
// Name: wx/variant.h
|
1998-09-12 17:31:48 +00:00
|
|
|
// Purpose: wxVariant class, container for any type
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 10/09/98
|
|
|
|
// RCS-ID: $Id$
|
2005-05-04 18:57:50 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-09-12 17:31:48 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_VARIANT_H_
|
|
|
|
#define _WX_VARIANT_H_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
2006-09-25 12:55:25 +00:00
|
|
|
|
|
|
|
#if wxUSE_VARIANT
|
|
|
|
|
1998-09-12 17:31:48 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
2003-07-19 15:05:08 +00:00
|
|
|
#include "wx/arrstr.h"
|
1998-09-12 17:31:48 +00:00
|
|
|
#include "wx/list.h"
|
|
|
|
|
2003-02-06 00:53:46 +00:00
|
|
|
#if wxUSE_DATETIME
|
|
|
|
#include "wx/datetime.h"
|
|
|
|
#endif // wxUSE_DATETIME
|
2001-06-10 17:04:00 +00:00
|
|
|
|
|
|
|
#if wxUSE_ODBC
|
|
|
|
#include "wx/db.h" // will #include sqltypes.h
|
|
|
|
#endif //ODBC
|
|
|
|
|
2003-01-26 00:12:12 +00:00
|
|
|
#include "wx/iosfwrap.h"
|
1998-09-12 17:31:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* wxVariantData stores the actual data in a wxVariant object,
|
|
|
|
* to allow it to store any type of data.
|
|
|
|
* Derive from this to provide custom data handling.
|
|
|
|
*
|
2006-09-30 11:20:14 +00:00
|
|
|
* NB: To prevent addition of extra vtbl pointer to wxVariantData,
|
|
|
|
* we don't multiple-inherit from wxObjectRefData. Instead,
|
|
|
|
* we simply replicate the wxObject ref-counting scheme.
|
|
|
|
*
|
|
|
|
* NB: When you construct a wxVariantData, it will have refcount
|
|
|
|
* of one. Refcount will not be further increased when
|
|
|
|
* it is passed to wxVariant. This simulates old common
|
|
|
|
* scenario where wxVariant took ownership of wxVariantData
|
|
|
|
* passed to it.
|
|
|
|
* If you create wxVariantData for other reasons than passing
|
|
|
|
* it to wxVariant, technically you are not required to call
|
|
|
|
* DecRef() before deleting it.
|
|
|
|
*
|
1998-09-12 17:31:48 +00:00
|
|
|
* TODO: in order to replace wxPropertyValue, we would need
|
|
|
|
* to consider adding constructors that take pointers to C++ variables,
|
|
|
|
* or removing that functionality from the wxProperty library.
|
|
|
|
* Essentially wxPropertyValue takes on some of the wxValidator functionality
|
|
|
|
* by storing pointers and not just actual values, allowing update of C++ data
|
|
|
|
* to be handled automatically. Perhaps there's another way of doing this without
|
|
|
|
* overloading wxVariant with unnecessary functionality.
|
|
|
|
*/
|
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxVariantData: public wxObject
|
1998-09-12 17:31:48 +00:00
|
|
|
{
|
2006-09-30 11:20:14 +00:00
|
|
|
friend class wxVariant;
|
1998-09-12 17:31:48 +00:00
|
|
|
public:
|
2006-09-30 11:20:14 +00:00
|
|
|
wxVariantData()
|
|
|
|
: wxObject(), m_count(1)
|
|
|
|
{ }
|
1998-09-12 17:31:48 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// Override these to provide common functionality
|
1998-09-12 17:31:48 +00:00
|
|
|
virtual bool Eq(wxVariantData& data) const = 0;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
1999-06-27 10:39:38 +00:00
|
|
|
#if wxUSE_STD_IOSTREAM
|
2006-10-02 07:09:20 +00:00
|
|
|
virtual bool Write(wxSTD ostream& WXUNUSED(str)) const { return false; }
|
1999-06-27 10:39:38 +00:00
|
|
|
#endif
|
2006-10-02 07:09:20 +00:00
|
|
|
virtual bool Write(wxString& WXUNUSED(str)) const { return false; }
|
1999-06-27 10:39:38 +00:00
|
|
|
#if wxUSE_STD_IOSTREAM
|
2006-10-02 07:09:20 +00:00
|
|
|
virtual bool Read(wxSTD istream& WXUNUSED(str)) { return false; }
|
1999-06-27 10:39:38 +00:00
|
|
|
#endif
|
2006-10-02 07:09:20 +00:00
|
|
|
virtual bool Read(wxString& WXUNUSED(str)) { return false; }
|
1998-09-12 17:31:48 +00:00
|
|
|
// What type is it? Return a string name.
|
|
|
|
virtual wxString GetType() const = 0;
|
2003-06-02 21:17:28 +00:00
|
|
|
// If it based on wxObject return the ClassInfo.
|
|
|
|
virtual wxClassInfo* GetValueClassInfo() { return NULL; }
|
2006-09-30 11:20:14 +00:00
|
|
|
|
|
|
|
void IncRef() { m_count++; }
|
|
|
|
void DecRef()
|
|
|
|
{
|
|
|
|
if ( --m_count == 0 )
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetRefCount() const { return m_count; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Protected dtor should make some incompatible code
|
|
|
|
// break more louder. That is, they should do data->DecRef()
|
|
|
|
// instead of delete data.
|
|
|
|
virtual ~wxVariantData() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_count;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
private:
|
|
|
|
DECLARE_ABSTRACT_CLASS(wxVariantData)
|
1998-09-12 17:31:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxVariant can store any kind of data, but has some basic types
|
|
|
|
* built in.
|
|
|
|
*/
|
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxVariant: public wxObject
|
1998-09-12 17:31:48 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxVariant();
|
2006-10-02 07:09:20 +00:00
|
|
|
|
1998-09-12 17:31:48 +00:00
|
|
|
wxVariant(const wxVariant& variant);
|
2006-09-30 11:20:14 +00:00
|
|
|
wxVariant(wxVariantData* data, const wxString& name = wxEmptyString);
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxVariant();
|
1998-09-12 17:31:48 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// generic assignment
|
1998-09-12 17:31:48 +00:00
|
|
|
void operator= (const wxVariant& variant);
|
|
|
|
|
|
|
|
// Assignment using data, e.g.
|
|
|
|
// myVariant = new wxStringVariantData("hello");
|
|
|
|
void operator= (wxVariantData* variantData);
|
2006-10-02 07:09:20 +00:00
|
|
|
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (const wxVariant& variant) const;
|
|
|
|
bool operator!= (const wxVariant& variant) const;
|
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// Sets/gets name
|
|
|
|
inline void SetName(const wxString& name) { m_name = name; }
|
|
|
|
inline const wxString& GetName() const { return m_name; }
|
|
|
|
|
|
|
|
// Tests whether there is data
|
2006-10-02 07:09:20 +00:00
|
|
|
bool IsNull() const;
|
2006-09-30 11:20:14 +00:00
|
|
|
|
|
|
|
// For compatibility with wxWidgets <= 2.6, this doesn't increase
|
|
|
|
// reference count.
|
|
|
|
wxVariantData* GetData() const { return m_data; }
|
|
|
|
void SetData(wxVariantData* data) ;
|
|
|
|
|
|
|
|
// make a 'clone' of the object
|
|
|
|
void Ref(const wxVariant& clone);
|
|
|
|
|
|
|
|
// destroy a reference
|
|
|
|
void UnRef();
|
|
|
|
|
|
|
|
// Make NULL (i.e. delete the data)
|
|
|
|
void MakeNull();
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// Delete data and name
|
|
|
|
void Clear();
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// Returns a string representing the type of the variant,
|
|
|
|
// e.g. "string", "bool", "stringlist", "list", "double", "long"
|
|
|
|
wxString GetType() const;
|
|
|
|
|
|
|
|
bool IsType(const wxString& type) const;
|
|
|
|
bool IsValueKindOf(const wxClassInfo* type) const;
|
|
|
|
|
2006-10-02 07:09:20 +00:00
|
|
|
// write contents to a string (e.g. for debugging)
|
2006-09-30 11:20:14 +00:00
|
|
|
wxString MakeString() const;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// double
|
|
|
|
wxVariant(double val, const wxString& name = wxEmptyString);
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (double value) const;
|
|
|
|
bool operator!= (double value) const;
|
|
|
|
void operator= (double value) ;
|
2006-09-30 11:20:14 +00:00
|
|
|
inline operator double () const { return GetDouble(); }
|
|
|
|
inline double GetReal() const { return GetDouble(); }
|
|
|
|
double GetDouble() const;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// long
|
|
|
|
wxVariant(long val, const wxString& name = wxEmptyString);
|
|
|
|
wxVariant(int val, const wxString& name = wxEmptyString);
|
|
|
|
wxVariant(short val, const wxString& name = wxEmptyString);
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (long value) const;
|
|
|
|
bool operator!= (long value) const;
|
|
|
|
void operator= (long value) ;
|
2006-09-30 11:20:14 +00:00
|
|
|
inline operator long () const { return GetLong(); }
|
|
|
|
inline long GetInteger() const { return GetLong(); }
|
|
|
|
long GetLong() const;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
|
|
|
// bool
|
1999-03-12 19:12:49 +00:00
|
|
|
#ifdef HAVE_BOOL
|
2006-09-30 11:20:14 +00:00
|
|
|
wxVariant(bool val, const wxString& name = wxEmptyString);
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (bool value) const;
|
|
|
|
bool operator!= (bool value) const;
|
|
|
|
void operator= (bool value) ;
|
2006-09-30 11:20:14 +00:00
|
|
|
inline operator bool () const { return GetBool(); }
|
|
|
|
bool GetBool() const ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// wxDateTime
|
|
|
|
#if wxUSE_DATETIME
|
2006-10-02 07:09:20 +00:00
|
|
|
wxVariant(const wxDateTime& val, const wxString& name = wxEmptyString);
|
2006-09-30 11:20:14 +00:00
|
|
|
#if wxUSE_ODBC
|
|
|
|
wxVariant(const DATE_STRUCT* valptr, const wxString& name = wxEmptyString);
|
|
|
|
wxVariant(const TIME_STRUCT* valptr, const wxString& name = wxEmptyString);
|
|
|
|
wxVariant(const TIMESTAMP_STRUCT* valptr, const wxString& name = wxEmptyString);
|
|
|
|
#endif
|
|
|
|
bool operator== (const wxDateTime& value) const;
|
|
|
|
bool operator!= (const wxDateTime& value) const;
|
|
|
|
void operator= (const wxDateTime& value) ;
|
|
|
|
#if wxUSE_ODBC
|
|
|
|
void operator= (const DATE_STRUCT* value) ;
|
|
|
|
void operator= (const TIME_STRUCT* value) ;
|
|
|
|
void operator= (const TIMESTAMP_STRUCT* value) ;
|
|
|
|
#endif
|
|
|
|
inline operator wxDateTime () const { return GetDateTime(); }
|
|
|
|
wxDateTime GetDateTime() const;
|
1999-03-12 19:12:49 +00:00
|
|
|
#endif
|
2006-09-30 11:20:14 +00:00
|
|
|
|
|
|
|
// wxString
|
|
|
|
wxVariant(const wxString& val, const wxString& name = wxEmptyString);
|
|
|
|
wxVariant(const wxChar* val, const wxString& name = wxEmptyString); // Necessary or VC++ assumes bool!
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (const wxString& value) const;
|
|
|
|
bool operator!= (const wxString& value) const;
|
|
|
|
void operator= (const wxString& value) ;
|
1999-04-13 11:43:03 +00:00
|
|
|
void operator= (const wxChar* value) ; // Necessary or VC++ assumes bool!
|
2006-09-30 11:20:14 +00:00
|
|
|
inline operator wxString () const { return MakeString(); }
|
|
|
|
wxString GetString() const;
|
|
|
|
|
2006-09-30 11:29:52 +00:00
|
|
|
// wxChar
|
|
|
|
wxVariant(wxChar val, const wxString& name = wxEmptyString);
|
|
|
|
bool operator== (wxChar value) const;
|
|
|
|
bool operator!= (wxChar value) const;
|
|
|
|
void operator= (wxChar value) ;
|
|
|
|
inline operator wxChar () const { return GetChar(); }
|
|
|
|
wxChar GetChar() const ;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
// wxArrayString
|
|
|
|
wxVariant(const wxArrayString& val, const wxString& name = wxEmptyString);
|
|
|
|
bool operator== (const wxArrayString& value) const;
|
|
|
|
bool operator!= (const wxArrayString& value) const;
|
|
|
|
void operator= (const wxArrayString& value);
|
|
|
|
inline operator wxArrayString () const { return GetArrayString(); }
|
|
|
|
wxArrayString GetArrayString() const;
|
|
|
|
|
|
|
|
// void*
|
|
|
|
wxVariant(void* ptr, const wxString& name = wxEmptyString);
|
|
|
|
bool operator== (void* value) const;
|
|
|
|
bool operator!= (void* value) const;
|
|
|
|
void operator= (void* value);
|
|
|
|
inline operator void* () const { return GetVoidPtr(); }
|
|
|
|
void* GetVoidPtr() const;
|
|
|
|
|
|
|
|
// wxObject*
|
|
|
|
wxVariant(wxObject* ptr, const wxString& name = wxEmptyString);
|
|
|
|
bool operator== (wxObject* value) const;
|
|
|
|
bool operator!= (wxObject* value) const;
|
|
|
|
void operator= (wxObject* value);
|
|
|
|
wxObject* GetWxObjectPtr() const;
|
|
|
|
|
|
|
|
|
2005-02-07 22:51:30 +00:00
|
|
|
#if WXWIN_COMPATIBILITY_2_4
|
2006-09-30 11:20:14 +00:00
|
|
|
wxDEPRECATED( wxVariant(const wxStringList& val, const wxString& name = wxEmptyString) );
|
2005-02-07 22:51:30 +00:00
|
|
|
wxDEPRECATED( bool operator== (const wxStringList& value) const );
|
|
|
|
wxDEPRECATED( bool operator!= (const wxStringList& value) const );
|
|
|
|
wxDEPRECATED( void operator= (const wxStringList& value) );
|
2006-09-30 11:20:14 +00:00
|
|
|
wxDEPRECATED( wxStringList& GetStringList() const );
|
2005-02-07 22:51:30 +00:00
|
|
|
#endif
|
2006-09-30 11:20:14 +00:00
|
|
|
|
|
|
|
// ------------------------------
|
|
|
|
// list operations
|
|
|
|
// ------------------------------
|
|
|
|
|
|
|
|
wxVariant(const wxList& val, const wxString& name = wxEmptyString); // List of variants
|
1998-09-12 17:31:48 +00:00
|
|
|
bool operator== (const wxList& value) const;
|
|
|
|
bool operator!= (const wxList& value) const;
|
|
|
|
void operator= (const wxList& value) ;
|
|
|
|
// Treat a list variant as an array
|
|
|
|
wxVariant operator[] (size_t idx) const;
|
|
|
|
wxVariant& operator[] (size_t idx) ;
|
2006-09-30 11:20:14 +00:00
|
|
|
wxList& GetList() const ;
|
1998-09-12 17:31:48 +00:00
|
|
|
|
|
|
|
// Return the number of elements in a list
|
2006-03-12 14:49:25 +00:00
|
|
|
size_t GetCount() const;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
1998-09-12 17:31:48 +00:00
|
|
|
// Make empty list
|
|
|
|
void NullList();
|
|
|
|
|
|
|
|
// Append to list
|
|
|
|
void Append(const wxVariant& value);
|
|
|
|
|
|
|
|
// Insert at front of list
|
|
|
|
void Insert(const wxVariant& value);
|
|
|
|
|
2004-09-24 14:32:35 +00:00
|
|
|
// Returns true if the variant is a member of the list
|
1998-09-12 17:31:48 +00:00
|
|
|
bool Member(const wxVariant& value) const;
|
|
|
|
|
|
|
|
// Deletes the nth element of the list
|
2006-03-12 14:49:25 +00:00
|
|
|
bool Delete(size_t item);
|
1998-09-12 17:31:48 +00:00
|
|
|
|
|
|
|
// Clear list
|
|
|
|
void ClearList();
|
|
|
|
|
2002-08-01 20:00:55 +00:00
|
|
|
public:
|
2006-09-30 11:20:14 +00:00
|
|
|
// Type conversion
|
1998-09-12 17:31:48 +00:00
|
|
|
bool Convert(long* value) const;
|
|
|
|
bool Convert(bool* value) const;
|
|
|
|
bool Convert(double* value) const;
|
|
|
|
bool Convert(wxString* value) const;
|
2006-09-30 21:01:04 +00:00
|
|
|
bool Convert(wxChar* value) const;
|
2003-02-06 00:53:46 +00:00
|
|
|
#if wxUSE_DATETIME
|
2001-06-10 17:04:00 +00:00
|
|
|
bool Convert(wxDateTime* value) const;
|
2003-02-06 00:53:46 +00:00
|
|
|
#endif // wxUSE_DATETIME
|
1998-09-12 17:31:48 +00:00
|
|
|
|
|
|
|
// Attributes
|
|
|
|
protected:
|
|
|
|
wxVariantData* m_data;
|
1998-11-29 21:20:12 +00:00
|
|
|
wxString m_name;
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 11:20:14 +00:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxVariant)
|
1998-09-12 17:31:48 +00:00
|
|
|
};
|
|
|
|
|
2006-09-30 20:45:15 +00:00
|
|
|
/* Fake macro parameter value */
|
|
|
|
#ifdef EMPTY_PARAMETER_VALUE
|
|
|
|
#undef EMPTY_PARAMETER_VALUE
|
|
|
|
#endif
|
2006-10-02 07:09:20 +00:00
|
|
|
#define EMPTY_PARAMETER_VALUE
|
2006-09-30 15:37:52 +00:00
|
|
|
|
|
|
|
#define DECLARE_VARIANT_OBJECT(classname) \
|
2006-09-30 20:45:15 +00:00
|
|
|
DECLARE_VARIANT_OBJECT_EXPORTED(classname,EMPTY_PARAMETER_VALUE)
|
2006-10-02 07:09:20 +00:00
|
|
|
|
2006-09-30 20:45:15 +00:00
|
|
|
#define DECLARE_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
|
2006-10-02 09:00:12 +00:00
|
|
|
expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
|
|
|
|
expdecl wxVariant& operator << ( wxVariant &variant, const classname &object );
|
2006-09-30 15:37:52 +00:00
|
|
|
|
|
|
|
#define IMPLEMENT_VARIANT_OBJECT(classname) \
|
2006-09-30 20:45:15 +00:00
|
|
|
IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,EMPTY_PARAMETER_VALUE)
|
|
|
|
|
2006-10-30 19:26:48 +00:00
|
|
|
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
|
2006-09-30 15:37:52 +00:00
|
|
|
class classname##VariantData: public wxVariantData \
|
|
|
|
{ \
|
|
|
|
public:\
|
|
|
|
classname##VariantData() {} \
|
|
|
|
classname##VariantData( const classname &value ) { m_value = value; } \
|
|
|
|
\
|
|
|
|
classname &GetValue() { return m_value; } \
|
|
|
|
\
|
|
|
|
virtual bool Eq(wxVariantData& data) const; \
|
|
|
|
\
|
|
|
|
virtual wxString GetType() const; \
|
|
|
|
virtual wxClassInfo* GetValueClassInfo(); \
|
|
|
|
\
|
|
|
|
protected:\
|
|
|
|
classname m_value; \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
DECLARE_CLASS(classname##VariantData) \
|
|
|
|
};\
|
|
|
|
\
|
|
|
|
IMPLEMENT_CLASS(classname##VariantData, wxVariantData)\
|
|
|
|
\
|
|
|
|
wxString classname##VariantData::GetType() const\
|
|
|
|
{\
|
|
|
|
return m_value.GetClassInfo()->GetClassName();\
|
|
|
|
}\
|
|
|
|
\
|
|
|
|
wxClassInfo* classname##VariantData::GetValueClassInfo()\
|
|
|
|
{\
|
|
|
|
return m_value.GetClassInfo();\
|
|
|
|
}\
|
|
|
|
\
|
2006-10-02 09:00:12 +00:00
|
|
|
expdecl classname& operator << ( classname &value, const wxVariant &variant )\
|
2006-09-30 15:37:52 +00:00
|
|
|
{\
|
|
|
|
wxASSERT( wxIsKindOf( variant.GetData(), classname##VariantData ) );\
|
|
|
|
\
|
|
|
|
classname##VariantData *data = (classname##VariantData*) variant.GetData();\
|
|
|
|
value = data->GetValue();\
|
|
|
|
return value;\
|
|
|
|
}\
|
|
|
|
\
|
2006-10-02 09:00:12 +00:00
|
|
|
expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
|
2006-09-30 15:37:52 +00:00
|
|
|
{\
|
|
|
|
classname##VariantData *data = new classname##VariantData( value );\
|
|
|
|
variant.SetData( data );\
|
|
|
|
return variant;\
|
|
|
|
}
|
|
|
|
|
2006-10-30 19:26:48 +00:00
|
|
|
// 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,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::IsRefTo function)
|
|
|
|
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \
|
|
|
|
IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
|
|
|
|
\
|
|
|
|
bool classname##VariantData::Eq(wxVariantData& data) const \
|
|
|
|
{\
|
|
|
|
wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
|
|
|
|
\
|
|
|
|
classname##VariantData & otherData = (classname##VariantData &) data;\
|
|
|
|
\
|
|
|
|
return (otherData.m_value.IsRefTo(&m_value));\
|
|
|
|
}\
|
|
|
|
|
|
|
|
|
2006-09-30 15:37:52 +00:00
|
|
|
// 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.
|
2003-06-02 21:17:28 +00:00
|
|
|
|
|
|
|
#define wxGetVariantCast(var,classname) \
|
2004-09-24 14:32:35 +00:00
|
|
|
((classname*)(var.IsValueKindOf(&classname::ms_classInfo) ?\
|
|
|
|
var.GetWxObjectPtr() : NULL));
|
2003-06-02 21:17:28 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
extern wxVariant WXDLLIMPEXP_BASE wxNullVariant;
|
1998-11-29 21:20:12 +00:00
|
|
|
|
2006-09-25 12:55:25 +00:00
|
|
|
#endif // wxUSE_VARIANT
|
|
|
|
|
|
|
|
#endif // _WX_VARIANT_H_
|