cmStringCommand.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. bool HandleUuidCommand(std::vector<std::string> const& args);
  69. class RegexReplacement
  70. {
  71. public:
  72. RegexReplacement(const char* s): number(-1), value(s) {}
  73. RegexReplacement(const std::string& s): number(-1), value(s) {}
  74. RegexReplacement(int n): number(n), value() {}
  75. RegexReplacement() {}
  76. int number;
  77. std::string value;
  78. };
  79. };
  80. #endif