Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Source / cmExecutionStatus.h
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
5 #include <cmConfigure.h> // IWYU pragma: keep
6
7 #include <string>
8 #include <vector>
9
10 class cmMakefile;
11
12 /** \class cmExecutionStatus
13  * \brief Superclass for all command status classes
14  *
15  * when a command is involked it may set values on a command status instance
16  */
17 class cmExecutionStatus
18 {
19 public:
20   cmExecutionStatus(cmMakefile& makefile)
21     : Makefile(makefile)
22     , Error("unknown error.")
23   {
24   }
25
26   cmMakefile& GetMakefile() { return this->Makefile; }
27
28   void SetError(std::string const& e) { this->Error = e; }
29   std::string const& GetError() const { return this->Error; }
30
31   void SetReturnInvoked()
32   {
33     this->Variables.clear();
34     this->ReturnInvoked = true;
35   }
36   void SetReturnInvoked(std::vector<std::string> variables)
37   {
38     this->Variables = std::move(variables);
39     this->ReturnInvoked = true;
40   }
41   bool GetReturnInvoked() const { return this->ReturnInvoked; }
42   const std::vector<std::string>& GetReturnVariables() const
43   {
44     return this->Variables;
45   }
46
47   void SetBreakInvoked() { this->BreakInvoked = true; }
48   bool GetBreakInvoked() const { return this->BreakInvoked; }
49
50   void SetContinueInvoked() { this->ContinueInvoked = true; }
51   bool GetContinueInvoked() const { return this->ContinueInvoked; }
52
53   void SetNestedError() { this->NestedError = true; }
54   bool GetNestedError() const { return this->NestedError; }
55
56 private:
57   cmMakefile& Makefile;
58   std::string Error;
59   bool ReturnInvoked = false;
60   bool BreakInvoked = false;
61   bool ContinueInvoked = false;
62   bool NestedError = false;
63   std::vector<std::string> Variables;
64 };