cmWhileCommand.h 3.1 KB

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