1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
9 #include "cmsys/RegularExpression.hxx"
13 class cmStringReplaceHelper
16 cmStringReplaceHelper(const std::string
& regex
, std::string replace_expr
,
17 cmMakefile
* makefile
= nullptr);
19 bool IsRegularExpressionValid() const
21 return this->RegularExpression
.is_valid();
23 bool IsReplaceExpressionValid() const
25 return this->ValidReplaceExpression
;
28 bool Replace(const std::string
& input
, std::string
& output
);
30 const std::string
& GetError() { return this->ErrorString
; }
33 class RegexReplacement
36 RegexReplacement(const char* s
)
41 RegexReplacement(std::string s
)
46 RegexReplacement(int n
)
50 RegexReplacement() = default;
56 void ParseReplaceExpression();
58 std::string ErrorString
;
59 std::string RegExString
;
60 cmsys::RegularExpression RegularExpression
;
61 bool ValidReplaceExpression
= true;
62 std::string ReplaceExpression
;
63 std::vector
<RegexReplacement
> Replacements
;
64 cmMakefile
* Makefile
= nullptr;