diff options
| author | alpine <[email protected]> | 2020-06-04 16:13:19 +0200 |
|---|---|---|
| committer | alpine <[email protected]> | 2020-06-04 16:13:19 +0200 |
| commit | 28f66dee8a9fe49aadb5c1d67de48d9232363963 (patch) | |
| tree | 00f6bfd0c2120d005c833301830d167b0753feb3 /server/src/util/commands.h | |
| download | loader-28f66dee8a9fe49aadb5c1d67de48d9232363963.tar.xz loader-28f66dee8a9fe49aadb5c1d67de48d9232363963.zip | |
Initial commit
Diffstat (limited to 'server/src/util/commands.h')
| -rw-r--r-- | server/src/util/commands.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/src/util/commands.h b/server/src/util/commands.h new file mode 100644 index 0000000..1e5ae0f --- /dev/null +++ b/server/src/util/commands.h @@ -0,0 +1,21 @@ +#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; + } +}; |