cmStringCommand.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmStringCommand_h
  4. #define cmStringCommand_h
  5. #include "cmConfigure.h"
  6. #include <string>
  7. #include <vector>
  8. #include "cmCommand.h"
  9. class cmExecutionStatus;
  10. /** \class cmStringCommand
  11. * \brief Common string operations
  12. *
  13. */
  14. class cmStringCommand : public cmCommand
  15. {
  16. public:
  17. /**
  18. * This is a virtual constructor for the command.
  19. */
  20. cmCommand* Clone() CM_OVERRIDE { return new cmStringCommand; }
  21. /**
  22. * This is called when the command is first encountered in
  23. * the CMakeLists.txt file.
  24. */
  25. bool InitialPass(std::vector<std::string> const& args,
  26. cmExecutionStatus& status) CM_OVERRIDE;
  27. /**
  28. * The name of the command as specified in CMakeList.txt.
  29. */
  30. std::string GetName() const CM_OVERRIDE { return "string"; }
  31. protected:
  32. bool HandleConfigureCommand(std::vector<std::string> const& args);
  33. bool HandleAsciiCommand(std::vector<std::string> const& args);
  34. bool HandleRegexCommand(std::vector<std::string> const& args);
  35. bool RegexMatch(std::vector<std::string> const& args);
  36. bool RegexMatchAll(std::vector<std::string> const& args);
  37. bool RegexReplace(std::vector<std::string> const& args);
  38. bool HandleHashCommand(std::vector<std::string> const& args);
  39. bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
  40. bool toUpper);
  41. bool HandleCompareCommand(std::vector<std::string> const& args);
  42. bool HandleReplaceCommand(std::vector<std::string> const& args);
  43. bool HandleLengthCommand(std::vector<std::string> const& args);
  44. bool HandleSubstringCommand(std::vector<std::string> const& args);
  45. bool HandleAppendCommand(std::vector<std::string> const& args);
  46. bool HandleConcatCommand(std::vector<std::string> const& args);
  47. bool HandleStripCommand(std::vector<std::string> const& args);
  48. bool HandleRandomCommand(std::vector<std::string> const& args);
  49. bool HandleFindCommand(std::vector<std::string> const& args);
  50. bool HandleTimestampCommand(std::vector<std::string> const& args);
  51. bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
  52. bool HandleGenexStripCommand(std::vector<std::string> const& args);
  53. bool HandleUuidCommand(std::vector<std::string> const& args);
  54. class RegexReplacement
  55. {
  56. public:
  57. RegexReplacement(const char* s)
  58. : number(-1)
  59. , value(s)
  60. {
  61. }
  62. RegexReplacement(const std::string& s)
  63. : number(-1)
  64. , value(s)
  65. {
  66. }
  67. RegexReplacement(int n)
  68. : number(n)
  69. , value()
  70. {
  71. }
  72. RegexReplacement() {}
  73. int number;
  74. std::string value;
  75. };
  76. };
  77. #endif