common: add PROPERTY::IsValueDefined()

This commit is contained in:
Tomasz Wlostowski 2021-05-03 14:02:50 +02:00
parent d7e44b5181
commit 69e1891e42
1 changed files with 14 additions and 0 deletions

View File

@ -538,6 +538,16 @@ public:
return s_undef;
}
bool IsValueDefined( T value ) const
{
int idx = m_choices.Index( static_cast<int>( value ) );
if( idx >= 0 && idx < (int) m_choices.GetCount() )
return true;
return false;
}
const T ToEnum( const wxString value )
{
if( m_reverseMap.count( value ) )
@ -576,6 +586,10 @@ private:
{ \
type value = GetValue( src ); \
ENUM_MAP<type>& conv = ENUM_MAP<type>::Instance(); \
if( ! conv.IsValueDefined( value ) ) \
{ \
return false; \
} \
if( dstType->CheckType<wxString>() ) \
{ \
wxAnyValueTypeImpl<wxString>::SetValue( conv.ToString( value ), dst ); \