KiCad PCB EDA Suite
ENUM_MAP< T > Class Template Reference

#include <property.h>

Public Member Functions

ENUM_MAPMap (T aValue, const wxString &aName)
 
ENUM_MAPUndefined (T aValue)
 
const wxString & ToString (T value) const
 
bool IsValueDefined (T value) const
 
const T ToEnum (const wxString value)
 
wxPGChoices & Choices ()
 

Static Public Member Functions

static ENUM_MAP< T > & Instance ()
 

Private Member Functions

 ENUM_MAP ()
 

Private Attributes

wxPGChoices m_choices
 
std::unordered_map< wxString, T > m_reverseMap
 
m_undefined
 

Detailed Description

template<typename T>
class ENUM_MAP< T >

Definition at line 570 of file property.h.

Constructor & Destructor Documentation

◆ ENUM_MAP()

template<typename T >
ENUM_MAP< T >::ENUM_MAP ( )
inlineprivate

Definition at line 630 of file property.h.

633 {
634 }

Member Function Documentation

◆ Choices()

◆ Instance()

◆ IsValueDefined()

template<typename T >
bool ENUM_MAP< T >::IsValueDefined ( value) const
inline

Definition at line 604 of file property.h.

605 {
606 int idx = m_choices.Index( static_cast<int>( value ) );
607
608 if( idx >= 0 && idx < (int) m_choices.GetCount() )
609 return true;
610
611 return false;
612 }

References ENUM_MAP< T >::m_choices.

◆ Map()

template<typename T >
ENUM_MAP & ENUM_MAP< T >::Map ( aValue,
const wxString &  aName 
)
inline

◆ ToEnum()

template<typename T >
const T ENUM_MAP< T >::ToEnum ( const wxString  value)
inline

Definition at line 614 of file property.h.

615 {
616 if( m_reverseMap.count( value ) )
617 return m_reverseMap[ value ];
618 else
619 return m_undefined;
620 }
T m_undefined
Definition: property.h:630

References ENUM_MAP< T >::m_reverseMap, and ENUM_MAP< T >::m_undefined.

◆ ToString()

template<typename T >
const wxString & ENUM_MAP< T >::ToString ( value) const
inline

Definition at line 592 of file property.h.

593 {
594 static const wxString s_undef = "UNDEFINED";
595
596 int idx = m_choices.Index( static_cast<int>( value ) );
597
598 if( idx >= 0 && idx < (int) m_choices.GetCount() )
599 return m_choices.GetLabel( static_cast<int>( idx ) );
600 else
601 return s_undef;
602 }

References ENUM_MAP< T >::m_choices.

◆ Undefined()

Member Data Documentation

◆ m_choices

template<typename T >
wxPGChoices ENUM_MAP< T >::m_choices
private

◆ m_reverseMap

template<typename T >
std::unordered_map<wxString, T> ENUM_MAP< T >::m_reverseMap
private

Definition at line 629 of file property.h.

Referenced by ENUM_MAP< T >::Map(), and ENUM_MAP< T >::ToEnum().

◆ m_undefined

template<typename T >
T ENUM_MAP< T >::m_undefined
private

Definition at line 630 of file property.h.

Referenced by ENUM_MAP< T >::ToEnum(), and ENUM_MAP< T >::Undefined().


The documentation for this class was generated from the following file: