cmWhileCommand.h 3.0 KB

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