cmStringCommand.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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" // IWYU pragma: keep
  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() 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) override;
  27. protected:
  28. bool HandleConfigureCommand(std::vector<std::string> const& args);
  29. bool HandleAsciiCommand(std::vector<std::string> const& args);
  30. bool HandleRegexCommand(std::vector<std::string> const& args);
  31. bool RegexMatch(std::vector<std::string> const& args);
  32. bool RegexMatchAll(std::vector<std::string> const& args);
  33. bool RegexReplace(std::vector<std::string> const& args);
  34. bool HandleHashCommand(std::vector<std::string> const& args);
  35. bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
  36. bool toUpper);
  37. bool HandleCompareCommand(std::vector<std::string> const& args);
  38. bool HandleReplaceCommand(std::vector<std::string> const& args);
  39. bool HandleLengthCommand(std::vector<std::string> const& args);
  40. bool HandleSubstringCommand(std::vector<std::string> const& args);
  41. bool HandleAppendCommand(std::vector<std::string> const& args);
  42. bool HandlePrependCommand(std::vector<std::string> const& args);
  43. bool HandleConcatCommand(std::vector<std::string> const& args);
  44. bool HandleStripCommand(std::vector<std::string> const& args);
  45. bool HandleRandomCommand(std::vector<std::string> const& args);
  46. bool HandleFindCommand(std::vector<std::string> const& args);
  47. bool HandleTimestampCommand(std::vector<std::string> const& args);
  48. bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
  49. bool HandleGenexStripCommand(std::vector<std::string> const& args);
  50. bool HandleUuidCommand(std::vector<std::string> const& args);
  51. class RegexReplacement
  52. {
  53. public:
  54. RegexReplacement(const char* s)
  55. : number(-1)
  56. , value(s)
  57. {
  58. }
  59. RegexReplacement(const std::string& s)
  60. : number(-1)
  61. , value(s)
  62. {
  63. }
  64. RegexReplacement(int n)
  65. : number(n)
  66. , value()
  67. {
  68. }
  69. RegexReplacement() {}
  70. int number;
  71. std::string value;
  72. };
  73. };
  74. #endif