cmStringCommand.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "cmCommand.h"
  6. class cmMakefile;
  7. namespace cmsys {
  8. class RegularExpression;
  9. }
  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. * This determines if the command is invoked when in script mode.
  29. */
  30. bool IsScriptable() const CM_OVERRIDE { return true; }
  31. /**
  32. * The name of the command as specified in CMakeList.txt.
  33. */
  34. std::string GetName() const CM_OVERRIDE { return "string"; }
  35. cmTypeMacro(cmStringCommand, cmCommand);
  36. protected:
  37. bool HandleConfigureCommand(std::vector<std::string> const& args);
  38. bool HandleAsciiCommand(std::vector<std::string> const& args);
  39. bool HandleRegexCommand(std::vector<std::string> const& args);
  40. bool RegexMatch(std::vector<std::string> const& args);
  41. bool RegexMatchAll(std::vector<std::string> const& args);
  42. bool RegexReplace(std::vector<std::string> const& args);
  43. bool HandleHashCommand(std::vector<std::string> const& args);
  44. bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
  45. bool toUpper);
  46. bool HandleCompareCommand(std::vector<std::string> const& args);
  47. bool HandleReplaceCommand(std::vector<std::string> const& args);
  48. bool HandleLengthCommand(std::vector<std::string> const& args);
  49. bool HandleSubstringCommand(std::vector<std::string> const& args);
  50. bool HandleAppendCommand(std::vector<std::string> const& args);
  51. bool HandleConcatCommand(std::vector<std::string> const& args);
  52. bool HandleStripCommand(std::vector<std::string> const& args);
  53. bool HandleRandomCommand(std::vector<std::string> const& args);
  54. bool HandleFindCommand(std::vector<std::string> const& args);
  55. bool HandleTimestampCommand(std::vector<std::string> const& args);
  56. bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
  57. bool HandleGenexStripCommand(std::vector<std::string> const& args);
  58. bool HandleUuidCommand(std::vector<std::string> const& args);
  59. class RegexReplacement
  60. {
  61. public:
  62. RegexReplacement(const char* s)
  63. : number(-1)
  64. , value(s)
  65. {
  66. }
  67. RegexReplacement(const std::string& s)
  68. : number(-1)
  69. , value(s)
  70. {
  71. }
  72. RegexReplacement(int n)
  73. : number(n)
  74. , value()
  75. {
  76. }
  77. RegexReplacement() {}
  78. int number;
  79. std::string value;
  80. };
  81. };
  82. #endif