wxAnyValueType is base class for value type functionality for C++ data types used with wxAny.
Usually the default template will create a satisfactory wxAnyValueType implementation for a data type, but sometimes you may need to add some customization. To do this you will need to add specialized template of wxAnyValueTypeImpl<>. Often your only need may be to add dynamic type conversion which would be done like this:
template<>
class wxAnyValueTypeImpl<MyClass> :
public wxAnyValueTypeImplBase<MyClass>
{
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
public:
wxAnyValueTypeImpl() :
wxAnyValueTypeImplBase<MyClass>() { }
virtual ~wxAnyValueTypeImpl() { }
{
MyClass value = GetValue(src);
{
wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
}
else
{
return false;
}
}
};
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
wxAnyValueTypeImplBase<> template, from which we inherit in the above example, contains the bulk of the default wxAnyValueTypeImpl<> template implementation, and as such allows you to easily add some minor customization.
If you need a have complete control over the type interpretation, you will need to derive a class directly from wxAnyValueType, like this:
template <>
{
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
public:
{
buf.m_ptr = NULL;
}
{
}
{
}
static void SetValue(const T& value,
{
}
{
}
};
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
- See Also
- wxAny