This class can map strings(commands) and functions receiving no arguments returning an int value.

Dependents:   Interference_Simple StrCommandHandler_Demo

Revision:
4:59a5e39e3e91
Parent:
3:049a5f083f32
--- a/StrCommandHandler.cpp	Wed Nov 27 23:11:11 2019 +0000
+++ b/StrCommandHandler.cpp	Mon Aug 10 10:35:29 2020 +0000
@@ -11,12 +11,12 @@
     m_num_ofcommands(arg_num_ofcommands)
 {
     m_command_name = new char[m_num_ofcommands][16];
-    m_function = new (void * (* [m_num_ofcommands])(void));
+    m_function = new (void * (* [m_num_ofcommands])(const char * const));
 }
 
 void StrCommandHandler::map(
     const char * const   arg_command,
-    void * (*arg_pfunc)(void)
+    void * (*arg_pfunc)(const char * const)
 )
 {
     static int itr_push = 0;
@@ -26,10 +26,10 @@
     if (itr_push == m_num_ofcommands) {
         m_num_ofcommands += 5;
         char (*tmp_cm)[16]  = new char[m_num_ofcommands][16];
-        void * (**tmp_fu)(void)= new (void * (* [m_num_ofcommands])(void));
+        void * (**tmp_fu)(const char * const)= new (void * (* [m_num_ofcommands])(const char * const));
 
         memcpy(tmp_cm, m_command_name,  sizeof(char) * (m_num_ofcommands - 5) * 16);
-        memcpy(tmp_fu, m_function,      sizeof(void * (*)()) * (m_num_ofcommands - 5));
+        memcpy(tmp_fu, m_function,      sizeof(void * (*)(const char * const)) * (m_num_ofcommands - 5));
 
         delete[] m_command_name;
         delete[] m_function;
@@ -81,7 +81,7 @@
     //  Exception: Not registered Command
     if ( key == m_num_ofcommands ) return &(m_rescode = 0xFFFFFFFC);
 
-    return (*m_function[key])();;
+    return (*m_function[key])(arg_command);;
 }
 
 void StrCommandHandler::list()