MCPcopy Create free account
hub / github.com/apache/trafficserver / process

Method process

plugins/cachekey/pattern.cc:169–198  ·  view source on GitHub ↗

* @brief Capture or capture-and-replace depending on whether a replacement string is specified. * @see replace() * @see capture() * @param subject PCRE subject string * @param result vector of strings where the result of captures or the replacements will be returned. * @return true if there was a match and capture or replacement succeeded, false if failure. */

Source from the content-addressed store, hash-verified

167 * @return true if there was a match and capture or replacement succeeded, false if failure.
168 */
169bool
170Pattern::process(const String &subject, StringVector &result)
171{
172 if (_replace) {
173 /* Replacement pattern was provided in the configuration - capture and replace. */
174 String element;
175 if (replace(subject, element)) {
176 result.push_back(element);
177 } else {
178 return false;
179 }
180 } else {
181 /* Replacement was not provided so return all capturing groups except the group zero. */
182 StringVector captures;
183 if (capture(subject, captures)) {
184 if (captures.size() == 1) {
185 result.push_back(captures[0]);
186 } else {
187 StringVector::iterator it = captures.begin() + 1;
188 for (; it != captures.end(); it++) {
189 result.push_back(*it);
190 }
191 }
192 } else {
193 return false;
194 }
195 }
196
197 return true;
198}
199
200/**
201 * @brief PCRE matches a subject string against the regex pattern.

Callers 4

appendPrefixMethod · 0.45
appendPathMethod · 0.45
captureFromHeadersFunction · 0.45
appendUaCapturesMethod · 0.45

Calls 4

push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected