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

Constructor & Destructor Documentation

◆ Mapper()

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

Definition at line 281 of file cmdmapper.h.

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

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

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

References m_map.

◆ map()

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

Definition at line 256 of file cmdmapper.h.

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

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

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


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