cmMathCommand.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 cmMathCommand_h
  11. #define cmMathCommand_h
  12. #include "cmCommand.h"
  13. /** \class cmMathCommand
  14. * \brief Common string operations
  15. *
  16. */
  17. class cmMathCommand : public cmCommand
  18. {
  19. public:
  20. /**
  21. * This is a virtual constructor for the command.
  22. */
  23. virtual cmCommand* Clone()
  24. {
  25. return new cmMathCommand;
  26. }
  27. /**
  28. * This is called when the command is first encountered in
  29. * the CMakeLists.txt file.
  30. */
  31. virtual bool InitialPass(std::vector<std::string> const& args,
  32. cmExecutionStatus &status);
  33. /**
  34. * This determines if the command is invoked when in script mode.
  35. */
  36. virtual bool IsScriptable() { return true; }
  37. /**
  38. * The name of the command as specified in CMakeList.txt.
  39. */
  40. virtual const char* GetName() { return "math";}
  41. /**
  42. * Succinct documentation.
  43. */
  44. virtual const char* GetTerseDocumentation()
  45. {
  46. return "Mathematical expressions.";
  47. }
  48. /**
  49. * More documentation.
  50. */
  51. virtual const char* GetFullDocumentation()
  52. {
  53. return
  54. " math(EXPR <output variable> <math expression>)\n"
  55. "EXPR evaluates mathematical expression and return result in the "
  56. "output variable. Example mathematical expression is "
  57. "'5 * ( 10 + 13 )'. Supported operators are "
  58. "+ - * / % | & ^ ~ << >> * / %. They have the same meaning "
  59. " as they do in c code.";
  60. }
  61. cmTypeMacro(cmMathCommand, cmCommand);
  62. protected:
  63. bool HandleExprCommand(std::vector<std::string> const& args);
  64. };
  65. #endif