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

Method process

plugins/prefetch/pattern.cc:168–197  ·  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

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected