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 248 of file cmdmapper.h.

Constructor & Destructor Documentation

◆ Mapper()

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

Definition at line 271 of file cmdmapper.h.

272 {
273 }
Class representing a mapping from command names to command IDs.
Definition cmdmapper.h:249
const CommandMap< T > & m_map
Definition cmdmapper.h:276
bool m_cs
Definition cmdmapper.h:277

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 260 of file cmdmapper.h.

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

References m_map.

◆ map()

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

Definition at line 251 of file cmdmapper.h.

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

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 277 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 276 of file cmdmapper.h.

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


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