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>)
wxAnyValueType is base class for value type functionality for C++ data types used with wxAny.
Definition: any.h:383
virtual bool ConvertValue(const wxAnyValueBuffer &src, wxAnyValueType *dstType, wxAnyValueBuffer &dst) const =0
Convert value into buffer of different type.
bool CheckType() const
Use this template function for checking if wxAnyValueType represents a specific C++ data type.
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:315
Type for buffer within wxAny for holding data.
Definition: any.h:261
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:
{
}
{
}
{
}
static void SetValue(const T& value,
{
}
{
}
};
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
virtual void DeleteValue(wxAnyValueBuffer &buf) const =0
This function is called every time the data in wxAny buffer needs to be freed.
virtual void CopyBuffer(const wxAnyValueBuffer &src, wxAnyValueBuffer &dst) const =0
Implement this for buffer-to-buffer copy.
void * m_ptr
Definition: any.h:262
- See also
- wxAny