CommandParser.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include "CommandParser.h"
  8. #include "NewProjectCmd.h"
  9. #include "PlatformAddCmd.h"
  10. #include "BuildCmd.h"
  11. #include "ImportCmd.h"
  12. #include "PlayCmd.h"
  13. #include "EditCmd.h"
  14. #include "BindCmd.h"
  15. namespace ToolCore
  16. {
  17. CommandParser::CommandParser(Context* context) : Object(context)
  18. {
  19. }
  20. CommandParser::~CommandParser()
  21. {
  22. }
  23. Command* CommandParser::Parse(const Vector<String>& arguments)
  24. {
  25. Command* cmd = NULL;
  26. for (unsigned i = 0; i < arguments.Size(); ++i)
  27. {
  28. if (arguments[i].Length())
  29. {
  30. String argument = arguments[i].ToLower();
  31. if (argument == "new")
  32. {
  33. cmd = new NewProjectCmd(context_);
  34. }
  35. else if (argument == "build")
  36. {
  37. cmd = new BuildCmd(context_);
  38. }
  39. else if (argument == "platform-add")
  40. {
  41. cmd = new PlatformAddCmd(context_);
  42. }
  43. else if (argument == "import")
  44. {
  45. cmd = new ImportCmd(context_);
  46. }
  47. else if (argument == "play")
  48. {
  49. cmd = new PlayCmd(context_);
  50. }
  51. else if (argument == "edit")
  52. {
  53. cmd = new EditCmd(context_);
  54. }
  55. else if (argument == "bind")
  56. {
  57. cmd = new BindCmd(context_);
  58. }
  59. }
  60. if (cmd)
  61. {
  62. if (cmd->Parse(arguments, i, errorMsg_))
  63. return cmd;
  64. cmd->ReleaseRef();
  65. break;
  66. }
  67. }
  68. return NULL;
  69. }
  70. }