Doxygen
Loading...
Searching...
No Matches
Mapper< T > Class Template Reference

Class representing a mapping from command names to command IDs. More...

#include <src/cmdmapper.h>

Public Member Functions

map (const QCString &n) const
 
QCString find (const T n) const
 
 Mapper (const CommandMap< T > &cm, bool caseSensitive)
 

Private Attributes

const CommandMap< T > & m_map
 
bool m_cs
 

Detailed Description

template<typename T>
class Mapper< T >

Class representing a mapping from command names to command IDs.

Definition at line 246 of file cmdmapper.h.

Constructor & Destructor Documentation

◆ Mapper()

template<typename T >
Mapper< T >::Mapper ( const CommandMap< T > & cm,
bool caseSensitive )
inline

Definition at line 269 of file cmdmapper.h.

270 {
271 }
Class representing a mapping from command names to command IDs.
Definition cmdmapper.h:247
const CommandMap< T > & m_map
Definition cmdmapper.h:274
bool m_cs
Definition cmdmapper.h:275

References m_cs, and m_map.

Member Function Documentation

◆ find()

template<typename T >
QCString Mapper< T >::find ( const T n) const
inline

Definition at line 258 of file cmdmapper.h.

259 {
260 for (const auto &[name,id] : m_map)
261 {
262 T curVal = id;
263 // https://stackoverflow.com/a/15889501/1657886
264 if (curVal == n || (curVal == (static_cast<T>(static_cast<int>(n) | static_cast<int>(T::SIMPLESECT_BIT))))) return name.c_str();
265 }
266 return QCString();
267 }

References m_map.

◆ map()

template<typename T >
T Mapper< T >::map ( const QCString & n) const
inline

Definition at line 249 of file cmdmapper.h.

250 {
251 if (n.isEmpty()) return T::UNKNOWN;
252 QCString name = n;
253 if (!m_cs) name=name.lower();
254 auto it = m_map.find(name.str());
255 return it!=m_map.end() ? it->second : T::UNKNOWN;
256 }

References QCString::isEmpty(), QCString::lower(), m_cs, m_map, and QCString::str().

Member Data Documentation

◆ m_cs

template<typename T >
bool Mapper< T >::m_cs
private

Definition at line 275 of file cmdmapper.h.

Referenced by map(), and Mapper().

◆ m_map

template<typename T >
const CommandMap<T>& Mapper< T >::m_map
private

Definition at line 274 of file cmdmapper.h.

Referenced by find(), map(), and Mapper().


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