Numworks Epsilon
1.4.1
Graphing Calculator Operating System
command_handler.cpp
Go to the documentation of this file.
1
#include "
command_handler.h
"
2
#include <string.h>
3
4
namespace
Ion
{
5
namespace
Device {
6
namespace
Bench {
7
8
bool
CommandHandler::valid
()
const
{
9
return
(m_name !=
nullptr
&& m_function !=
nullptr
);
10
}
11
12
bool
CommandHandler::handle
(
const
char
* command)
const
{
13
if
(matches(command)) {
14
size_t
nameLength =
strlen
(m_name);
15
if
(command[nameLength] ==
'='
) {
16
m_function(command+nameLength+1);
// Skip the "Equal character"
17
}
else
{
18
m_function(
nullptr
);
19
}
20
return
true
;
21
}
22
return
false
;
23
}
24
25
bool
CommandHandler::matches(
const
char
* command)
const
{
26
const
char
*
c
= command;
27
const
char
* n = m_name;
28
while
(
true
) {
29
if
(*n ==
NULL
) {
30
if
(*
c
==
NULL
|| *
c
==
'='
) {
31
return
true
;
32
}
33
}
34
if
(*
c
!= *n) {
35
return
false
;
36
}
37
c
++;
38
n++;
39
}
40
}
41
42
}
43
}
44
}
Ion::Device::Bench::CommandHandler::handle
bool handle(const char *command) const
Definition:
command_handler.cpp:12
c
c(generic_all_nodes)
strlen
size_t strlen(const char *s)
Definition:
strlen.c:3
Ion::Device::Bench::CommandHandler::valid
bool valid() const
Definition:
command_handler.cpp:8
NULL
#define NULL
Definition:
stddef.h:4
command_handler.h
Ion
Definition:
backlight.h:6
epsilon
ion
src
device
bench
command_handler.cpp
Generated by
1.8.14