ENUM_MAP: support reverse (string-to-enum) mapping
This commit is contained in:
parent
5372daaedf
commit
7e8e02072e
|
@ -522,6 +522,7 @@ public:
|
|||
{
|
||||
wxASSERT_MSG( m_choices.Index( aName ) == wxNOT_FOUND, "Redefined string for a value in ENUM_MAP" );
|
||||
m_choices.Add( aName, static_cast<int>( aValue ) );
|
||||
m_reverseMap[ aName ] = aValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -530,6 +531,11 @@ public:
|
|||
return m_choices.GetLabel( static_cast<int>( value ) );
|
||||
}
|
||||
|
||||
const T ToEnum( const wxString value )
|
||||
{
|
||||
return m_reverseMap[value];
|
||||
}
|
||||
|
||||
const wxPGChoices& Choices() const
|
||||
{
|
||||
return m_choices;
|
||||
|
@ -537,6 +543,7 @@ public:
|
|||
|
||||
private:
|
||||
wxPGChoices m_choices;
|
||||
std::unordered_map<wxString, T> m_reverseMap;
|
||||
|
||||
ENUM_MAP<T>()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue