packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmWhileCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmWhileCommand_h
13 #define cmWhileCommand_h
14
15 #include "cmCommand.h"
16 #include "cmFunctionBlocker.h"
17 #include "cmListFileCache.h"
18
19 class cmWhileFunctionBlocker : public cmFunctionBlocker
20 {
21 public:
22   cmWhileFunctionBlocker() {this->Depth=0;}
23   virtual ~cmWhileFunctionBlocker() {}
24   virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
25                                  cmMakefile &mf,
26                                  cmExecutionStatus &);
27   virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
28
29   std::vector<cmListFileArgument> Args;
30   std::vector<cmListFileFunction> Functions;
31 private:
32   int Depth;
33 };
34
35 /// \brief Starts a while loop
36 class cmWhileCommand : public cmCommand
37 {
38 public:
39   /**
40    * This is a virtual constructor for the command.
41    */
42   virtual cmCommand* Clone()
43     {
44     return new cmWhileCommand;
45     }
46
47   /**
48    * This overrides the default InvokeInitialPass implementation.
49    * It records the arguments before expansion.
50    */
51   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
52                                  cmExecutionStatus &);
53
54   /**
55    * This is called when the command is first encountered in
56    * the CMakeLists.txt file.
57    */
58   virtual bool InitialPass(std::vector<std::string> const&,
59                            cmExecutionStatus &) { return false; }
60
61   /**
62    * This determines if the command is invoked when in script mode.
63    */
64   virtual bool IsScriptable() const { return true; }
65
66   /**
67    * The name of the command as specified in CMakeList.txt.
68    */
69   virtual const char* GetName() const { return "while";}
70
71   /**
72    * Succinct documentation.
73    */
74   virtual const char* GetTerseDocumentation() const
75     {
76     return "Evaluate a group of commands while a condition is true";
77     }
78
79   /**
80    * More documentation.
81    */
82   virtual const char* GetFullDocumentation() const
83     {
84     return
85       "  while(condition)\n"
86       "    COMMAND1(ARGS ...)\n"
87       "    COMMAND2(ARGS ...)\n"
88       "    ...\n"
89       "  endwhile(condition)\n"
90       "All commands between while and the matching endwhile are recorded "
91       "without being invoked.  Once the endwhile is evaluated, the "
92       "recorded list of commands is invoked as long as the condition "
93       "is true. The condition is evaluated using the same logic as the "
94       "if command.";
95     }
96
97   cmTypeMacro(cmWhileCommand, cmCommand);
98 };
99
100
101 #endif