blob: 3648df284da2696f3d700d1adfe2ea7d60621e4d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#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; }
};
|