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

Constructor & Destructor Documentation

◆ Mapper()

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

Definition at line 277 of file cmdmapper.h.

278 {
279 }
Class representing a mapping from command names to command IDs.
Definition cmdmapper.h:250
const CommandMap< T > & m_map
Definition cmdmapper.h:282
bool m_cs
Definition cmdmapper.h:283

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

262 {
264 for (const auto &[name,id] : m_map)
265 {
266 T curVal = id;
267 // https://stackoverflow.com/a/15889501/1657886
268 if (curVal == n || (curVal == (static_cast<T>(static_cast<int>(n) | static_cast<int>(T::SIMPLESECT_BIT)))))
269 {
270 result = name;
271 break;
272 }
273 }
274 return result;
275 }

References m_map.

◆ map()

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

Definition at line 252 of file cmdmapper.h.

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

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

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


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