cmExecutionStatus.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <cmConfigure.h> // IWYU pragma: keep
  5. #include <string>
  6. #include <vector>
  7. class cmMakefile;
  8. /** \class cmExecutionStatus
  9. * \brief Superclass for all command status classes
  10. *
  11. * when a command is involked it may set values on a command status instance
  12. */
  13. class cmExecutionStatus
  14. {
  15. public:
  16. cmExecutionStatus(cmMakefile& makefile)
  17. : Makefile(makefile)
  18. , Error("unknown error.")
  19. {
  20. }
  21. cmMakefile& GetMakefile() { return this->Makefile; }
  22. void SetError(std::string const& e) { this->Error = e; }
  23. std::string const& GetError() const { return this->Error; }
  24. void SetReturnInvoked()
  25. {
  26. this->Variables.clear();
  27. this->ReturnInvoked = true;
  28. }
  29. void SetReturnInvoked(std::vector<std::string> variables)
  30. {
  31. this->Variables = std::move(variables);
  32. this->ReturnInvoked = true;
  33. }
  34. bool GetReturnInvoked() const { return this->ReturnInvoked; }
  35. const std::vector<std::string>& GetReturnVariables() const
  36. {
  37. return this->Variables;
  38. }
  39. void SetBreakInvoked() { this->BreakInvoked = true; }
  40. bool GetBreakInvoked() const { return this->BreakInvoked; }
  41. void SetContinueInvoked() { this->ContinueInvoked = true; }
  42. bool GetContinueInvoked() const { return this->ContinueInvoked; }
  43. void SetNestedError() { this->NestedError = true; }
  44. bool GetNestedError() const { return this->NestedError; }
  45. private:
  46. cmMakefile& Makefile;
  47. std::string Error;
  48. bool ReturnInvoked = false;
  49. bool BreakInvoked = false;
  50. bool ContinueInvoked = false;
  51. bool NestedError = false;
  52. std::vector<std::string> Variables;
  53. };