Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CommandHandler::update()
- {
- if (ConsoleShell::IsThereACommand())
- {
- std::queue<std::string> commands;
- ConsoleShell::LockQueue();
- swap(commands, ConsoleShell::GetCommands());
- ConsoleShell::UnlockQueue();
- while (!commands.empty())
- {
- std::string c = commands.front();
- std::istringstream buf(c);
- std::istream_iterator<std::string> beg(buf), end;
- std::vector<std::string> tokens(beg, end);
- if (tokens.size() <= 0) continue;
- for (auto& cmd : possibleCommands)
- {
- if (cmd->parse(tokens))
- {
- cmd->execute();
- break;
- }
- }
- commands.pop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement