MCPcopy Create free account
hub / github.com/Kitware/CMake / Match

Method Match

Source/cmCMakeString.cxx:79–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77};
78
79cmList CMakeString::Match(std::string const& matchExpression,
80 MatchItems matchItems, cmMakefile* makefile) const
81{
82 if (makefile) {
83 makefile->ClearMatches();
84 }
85
86 // Compile the regular expression.
87 cmsys::RegularExpression re;
88 if (!re.compile(matchExpression)) {
89 throw std::invalid_argument(
90 cmStrCat("Failed to compile regex \"", matchExpression, '"'));
91 }
92
93 cmList output;
94 if (matchItems == MatchItems::Once) {
95 if (re.find(this->String_.data())) {
96 if (makefile) {
97 makefile->StoreMatches(re);
98 }
99 output.push_back(re.match());
100 }
101 } else {
102 unsigned optAnchor = 0;
103 if (makefile &&
104 makefile->GetPolicyStatus(cmPolicies::CMP0186) != cmPolicies::NEW) {
105 optAnchor = cmsys::RegularExpression::BOL_AT_OFFSET;
106 }
107
108 // Scan through the input for all matches.
109 std::string::size_type base = 0;
110 unsigned optNonEmpty = 0;
111 while (re.find(this->String_.data(), base, optAnchor | optNonEmpty)) {
112 if (makefile) {
113 makefile->ClearMatches();
114 makefile->StoreMatches(re);
115 }
116
117 output.push_back(re.match());
118 base = re.end();
119
120 if (re.start() == this->String_.length()) {
121 break;
122 }
123 if (re.start() == re.end()) {
124 optNonEmpty = cmsys::RegularExpression::NONEMPTY_AT_OFFSET;
125 } else {
126 optNonEmpty = 0;
127 }
128 }
129 }
130
131 return output;
132}
133
134CMakeString CMakeString::Substring(long begin, long count) const
135{

Callers 3

RegexMatchFunction · 0.45
RegexMatchAllFunction · 0.45
EvaluateMethod · 0.45

Calls 12

ClearMatchesMethod · 0.80
compileMethod · 0.80
StoreMatchesMethod · 0.80
push_backMethod · 0.80
lengthMethod · 0.80
cmStrCatFunction · 0.70
findMethod · 0.45
dataMethod · 0.45
matchMethod · 0.45
GetPolicyStatusMethod · 0.45
endMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected