cmStringCommand.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 cmStringCommand_h
  11. #define cmStringCommand_h
  12. #include "cmCommand.h"
  13. class cmMakefile;
  14. namespace cmsys
  15. {
  16. class RegularExpression;
  17. }
  18. /** \class cmStringCommand
  19. * \brief Common string operations
  20. *
  21. */
  22. class cmStringCommand : public cmCommand
  23. {
  24. public:
  25. /**
  26. * This is a virtual constructor for the command.
  27. */
  28. virtual cmCommand* Clone()
  29. {
  30. return new cmStringCommand;
  31. }
  32. /**
  33. * This is called when the command is first encountered in
  34. * the CMakeLists.txt file.
  35. */
  36. virtual bool InitialPass(std::vector<std::string> const& args,
  37. cmExecutionStatus &status);
  38. /**
  39. * This determines if the command is invoked when in script mode.
  40. */
  41. virtual bool IsScriptable() const { return true; }
  42. /**
  43. * The name of the command as specified in CMakeList.txt.
  44. */
  45. virtual std::string GetName() const { return "string";}
  46. cmTypeMacro(cmStringCommand, cmCommand);
  47. protected:
  48. bool HandleConfigureCommand(std::vector<std::string> const& args);
  49. bool HandleAsciiCommand(std::vector<std::string> const& args);
  50. bool HandleRegexCommand(std::vector<std::string> const& args);
  51. bool RegexMatch(std::vector<std::string> const& args);
  52. bool RegexMatchAll(std::vector<std::string> const& args);
  53. bool RegexReplace(std::vector<std::string> const& args);
  54. bool HandleHashCommand(std::vector<std::string> const& args);
  55. bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
  56. bool toUpper);
  57. bool HandleCompareCommand(std::vector<std::string> const& args);
  58. bool HandleReplaceCommand(std::vector<std::string> const& args);
  59. bool HandleLengthCommand(std::vector<std::string> const& args);
  60. bool HandleSubstringCommand(std::vector<std::string> const& args);
  61. bool HandleConcatCommand(std::vector<std::string> const& args);
  62. bool HandleStripCommand(std::vector<std::string> const& args);
  63. bool HandleRandomCommand(std::vector<std::string> const& args);
  64. bool HandleFindCommand(std::vector<std::string> const& args);
  65. bool HandleTimestampCommand(std::vector<std::string> const& args);
  66. bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
  67. bool HandleGenexStripCommand(std::vector<std::string> const& args);
  68. class RegexReplacement
  69. {
  70. public:
  71. RegexReplacement(const char* s): number(-1), value(s) {}
  72. RegexReplacement(const std::string& s): number(-1), value(s) {}
  73. RegexReplacement(int n): number(n), value() {}
  74. RegexReplacement() {}
  75. int number;
  76. std::string value;
  77. };
  78. };
  79. #endif