CommandParser.cpp 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "CommandParser.h"
  2. #include "NewProjectCmd.h"
  3. #include "BuildCmd.h"
  4. namespace ToolCore
  5. {
  6. CommandParser::CommandParser(Context* context) : Object(context)
  7. {
  8. }
  9. CommandParser::~CommandParser()
  10. {
  11. }
  12. Command* CommandParser::Parse(const Vector<String>& arguments)
  13. {
  14. Command* cmd = NULL;
  15. for (unsigned i = 0; i < arguments.Size(); ++i)
  16. {
  17. if (arguments[i].Length())
  18. {
  19. String argument = arguments[i].ToLower();
  20. if (argument == "new")
  21. {
  22. cmd = new NewProjectCmd(context_);
  23. }
  24. else if (argument == "build")
  25. {
  26. cmd = new BuildCmd(context_);
  27. }
  28. }
  29. if (cmd)
  30. {
  31. if (cmd->Parse(arguments, i, errorMsg_))
  32. return cmd;
  33. cmd->ReleaseRef();
  34. break;
  35. }
  36. }
  37. return NULL;
  38. }
  39. }