summaryrefslogtreecommitdiffstats
path: root/src/cmdmapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmdmapper.cpp')
-rw-r--r--src/cmdmapper.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp
index c4379e3..9a723c2 100644
--- a/src/cmdmapper.cpp
+++ b/src/cmdmapper.cpp
@@ -18,6 +18,13 @@
#include "cmdmapper.h"
+/** Call representing a mapping from a command name to a command ID. */
+struct CommandMap
+{
+ const char *cmdName;
+ int cmdId;
+};
+
CommandMap cmdMap[] =
{
{ "a", CMD_EMPHASIS },
@@ -198,6 +205,25 @@ CommandMap htmlTagMap[] =
Mapper *Mappers::cmdMapper = new Mapper(cmdMap,TRUE);
Mapper *Mappers::htmlTagMapper = new Mapper(htmlTagMap,FALSE);
+int Mapper::map(const char *n)
+{
+ QCString name=n;
+ if (!m_cs) name=name.lower();
+ int *result;
+ return !name.isEmpty() && (result=m_map.find(name)) ? *result: 0;
+}
+
+Mapper::Mapper(const CommandMap *cm,bool caseSensitive) : m_map(89), m_cs(caseSensitive)
+{
+ m_map.setAutoDelete(TRUE);
+ const CommandMap *p = cm;
+ while (p->cmdName)
+ {
+ m_map.insert(p->cmdName,new int(p->cmdId));
+ p++;
+ }
+}
+
void Mappers::freeMappers()
{
delete cmdMapper; cmdMapper = 0;