1
0

cmStringCommand.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. static void ClearMatches(cmMakefile* mf);
  48. static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re);
  49. protected:
  50. bool HandleConfigureCommand(std::vector<std::string> const& args);
  51. bool HandleAsciiCommand(std::vector<std::string> const& args);
  52. bool HandleRegexCommand(std::vector<std::string> const& args);
  53. bool RegexMatch(std::vector<std::string> const& args);
  54. bool RegexMatchAll(std::vector<std::string> const& args);
  55. bool RegexReplace(std::vector<std::string> const& args);
  56. bool HandleHashCommand(std::vector<std::string> const& args);
  57. bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
  58. bool toUpper);
  59. bool HandleCompareCommand(std::vector<std::string> const& args);
  60. bool HandleReplaceCommand(std::vector<std::string> const& args);
  61. bool HandleLengthCommand(std::vector<std::string> const& args);
  62. bool HandleSubstringCommand(std::vector<std::string> const& args);
  63. bool HandleConcatCommand(std::vector<std::string> const& args);
  64. bool HandleStripCommand(std::vector<std::string> const& args);
  65. bool HandleRandomCommand(std::vector<std::string> const& args);
  66. bool HandleFindCommand(std::vector<std::string> const& args);
  67. bool HandleTimestampCommand(std::vector<std::string> const& args);
  68. bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
  69. bool HandleGenexStripCommand(std::vector<std::string> const& args);
  70. class RegexReplacement
  71. {
  72. public:
  73. RegexReplacement(const char* s): number(-1), value(s) {}
  74. RegexReplacement(const std::string& s): number(-1), value(s) {}
  75. RegexReplacement(int n): number(n), value() {}
  76. RegexReplacement() {};
  77. int number;
  78. std::string value;
  79. };
  80. };
  81. #endif