BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
qdesigner_internal::MetaEnum< IntType > Class Template Reference

Public Types

typedef QMap< QString, IntType > KeyToValueMap
 

Public Member Functions

 MetaEnum ()
 
 MetaEnum (const QString &name, const QString &scope, const QString &separator)
 
void addKey (IntType value, const QString &name)
 
const QStringList & keys () const
 
IntType keyToValue (QString key, bool *ok=0) const
 
const KeyToValueMapkeyToValueMap () const
 
const QString & name () const
 
const QString & scope () const
 
const QString & separator () const
 
QString valueToKey (IntType value, bool *ok=0) const
 

Protected Member Functions

void appendQualifiedName (const QString &key, QString &target) const
 

Private Attributes

QStringList m_keys
 
KeyToValueMap m_keyToValueMap
 
QString m_name
 
QString m_scope
 
QString m_separator
 

Detailed Description

template<class IntType>
class qdesigner_internal::MetaEnum< IntType >

Definition at line 91 of file qdesigner_utils_p.h.

Member Typedef Documentation

◆ KeyToValueMap

template<class IntType >
typedef QMap<QString, IntType> qdesigner_internal::MetaEnum< IntType >::KeyToValueMap

Definition at line 93 of file qdesigner_utils_p.h.

Constructor & Destructor Documentation

◆ MetaEnum() [1/2]

template<class IntType >
qdesigner_internal::MetaEnum< IntType >::MetaEnum ( const QString &  name,
const QString &  scope,
const QString &  separator 
)

◆ MetaEnum() [2/2]

template<class IntType >
qdesigner_internal::MetaEnum< IntType >::MetaEnum ( )
inline

Definition at line 96 of file qdesigner_utils_p.h.

96 {}

Member Function Documentation

◆ addKey()

template<class IntType >
void qdesigner_internal::MetaEnum< IntType >::addKey ( IntType  value,
const QString &  name 
)

Definition at line 127 of file qdesigner_utils_p.h.

128 {
129  m_keyToValueMap.insert(name, value);
130  m_keys.append(name);
131 }

References RealSpace::Particles::name().

Here is the call graph for this function:

◆ appendQualifiedName()

template<class IntType >
void qdesigner_internal::MetaEnum< IntType >::appendQualifiedName ( const QString &  key,
QString &  target 
) const
protected

Definition at line 153 of file qdesigner_utils_p.h.

154 {
155  if (!m_scope.isEmpty()) {
156  target += m_scope;
157  target += m_separator;
158  }
159  target += key;
160 }

◆ keys()

template<class IntType >
const QStringList& qdesigner_internal::MetaEnum< IntType >::keys ( ) const
inline

Definition at line 107 of file qdesigner_utils_p.h.

107 { return m_keys; }

References qdesigner_internal::MetaEnum< IntType >::m_keys.

◆ keyToValue()

template<class IntType >
IntType qdesigner_internal::MetaEnum< IntType >::keyToValue ( QString  key,
bool *  ok = 0 
) const

Definition at line 141 of file qdesigner_utils_p.h.

142 {
143  if (!m_scope.isEmpty() && key.startsWith(m_scope))
144  key.remove(0, m_scope.size() + m_separator.size());
145  const typename KeyToValueMap::const_iterator it = m_keyToValueMap.find(key);
146  const bool found = it != m_keyToValueMap.constEnd();
147  if (ok)
148  *ok = found;
149  return found ? it.value() : IntType(0);
150 }

◆ keyToValueMap()

template<class IntType >
const KeyToValueMap& qdesigner_internal::MetaEnum< IntType >::keyToValueMap ( ) const
inline

Definition at line 108 of file qdesigner_utils_p.h.

108 { return m_keyToValueMap; }

References qdesigner_internal::MetaEnum< IntType >::m_keyToValueMap.

◆ name()

template<class IntType >
const QString& qdesigner_internal::MetaEnum< IntType >::name ( ) const
inline

Definition at line 103 of file qdesigner_utils_p.h.

103 { return m_name; }

References qdesigner_internal::MetaEnum< IntType >::m_name.

◆ scope()

template<class IntType >
const QString& qdesigner_internal::MetaEnum< IntType >::scope ( ) const
inline

Definition at line 104 of file qdesigner_utils_p.h.

104 { return m_scope; }

References qdesigner_internal::MetaEnum< IntType >::m_scope.

◆ separator()

template<class IntType >
const QString& qdesigner_internal::MetaEnum< IntType >::separator ( ) const
inline

Definition at line 105 of file qdesigner_utils_p.h.

105 { return m_separator; }

References qdesigner_internal::MetaEnum< IntType >::m_separator.

◆ valueToKey()

template<class IntType >
QString qdesigner_internal::MetaEnum< IntType >::valueToKey ( IntType  value,
bool *  ok = 0 
) const

Definition at line 133 of file qdesigner_utils_p.h.

134 {
135  const QString rc = m_keyToValueMap.key(value);
136  if (ok)
137  *ok = !rc.isEmpty();
138  return rc;
139 }

Member Data Documentation

◆ m_keys

template<class IntType >
QStringList qdesigner_internal::MetaEnum< IntType >::m_keys
private

Definition at line 118 of file qdesigner_utils_p.h.

Referenced by qdesigner_internal::MetaEnum< IntType >::keys().

◆ m_keyToValueMap

template<class IntType >
KeyToValueMap qdesigner_internal::MetaEnum< IntType >::m_keyToValueMap
private

◆ m_name

template<class IntType >
QString qdesigner_internal::MetaEnum< IntType >::m_name
private

Definition at line 114 of file qdesigner_utils_p.h.

Referenced by qdesigner_internal::MetaEnum< IntType >::name().

◆ m_scope

template<class IntType >
QString qdesigner_internal::MetaEnum< IntType >::m_scope
private

Definition at line 115 of file qdesigner_utils_p.h.

Referenced by qdesigner_internal::MetaEnum< IntType >::scope().

◆ m_separator

template<class IntType >
QString qdesigner_internal::MetaEnum< IntType >::m_separator
private

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