blob: 547a78ced80c9b995cfc69152a274d1cf16640c1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#pragma once
class commands {
using func = std::function<void()>;
std::unordered_map<std::string_view, func> m_cmds;
public:
bool parse_input(const std::string_view str)
{
auto it = m_cmds.find(str);
if(it != m_cmds.end()) {
it->second();
return true;
}
return false;
}
void add(const std::string_view cmd, const func& cb) { m_cmds[cmd] = cb; }
};
|