Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. void CommandHandler::update()
  2. {
  3. if (ConsoleShell::IsThereACommand())
  4. {
  5. std::queue<std::string> commands;
  6.  
  7. ConsoleShell::LockQueue();
  8. swap(commands, ConsoleShell::GetCommands());
  9. ConsoleShell::UnlockQueue();
  10.  
  11. while (!commands.empty())
  12. {
  13. std::string c = commands.front();
  14.  
  15. std::istringstream buf(c);
  16. std::istream_iterator<std::string> beg(buf), end;
  17.  
  18. std::vector<std::string> tokens(beg, end);
  19.  
  20. if (tokens.size() <= 0) continue;
  21.  
  22. for (auto& cmd : possibleCommands)
  23. {
  24. if (cmd->parse(tokens))
  25. {
  26. cmd->execute();
  27. break;
  28. }
  29. }
  30.  
  31. commands.pop();
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement