MCPcopy Create free account
hub / github.com/ImageEngine/cortex / matchWalk

Method matchWalk

src/IECore/PathMatcher.cpp:250–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250void PathMatcher::matchWalk( const Node *node, const NameIterator &start, const NameIterator &end, unsigned &result ) const
251{
252 // see if we've matched to the end of the path, and terminate the recursion if we have.
253 if( start == end )
254 {
255 if( node->terminator )
256 {
257 result |= ExactMatch;
258 }
259 if( node->children.size() )
260 {
261 result |= DescendantMatch;
262 }
263 if( const Node *ellipsis = node->child( g_ellipsis ) )
264 {
265 result |= DescendantMatch;
266 if( ellipsis->terminator )
267 {
268 result |= ExactMatch;
269 }
270 }
271 return;
272 }
273
274 // we haven't matched to the end of the path - there are still path elements
275 // to check. if this node is a terminator then we have found an ancestor match
276 // though.
277 if( node->terminator )
278 {
279 result |= AncestorMatch;
280 }
281
282 // now we can match the remainder of the path against child branches to see
283 // if we have any exact or descendant matches.
284 ///////////////////////////////////////////////////////////////////////////
285
286 // first check for a child with the exact name we're looking for.
287 // we can use the specialised Name constructor to explicitly say we're
288 // not interested in finding a child with wildcards here - this avoids
289 // a call to hasWildcards() and gives us a decent little performance boost.
290
291 Node::ConstChildMapIterator childIt = node->children.find( Name( *start, Name::Plain ) );
292 const Node::ConstChildMapIterator childItEnd = node->children.end();
293 if( childIt != childItEnd )
294 {
295 NameIterator newStart = start + 1;
296 matchWalk( childIt->second.get(), newStart, end, result );
297 // if we've found every kind of match then we can terminate early,
298 // but otherwise we need to keep going even though we may
299 // have found some of the match types already.
300 if( result == EveryMatch )
301 {
302 return;
303 }
304 }
305
306 // then check all the wildcarded children to see if they might match.
307

Callers

nothing calls this directly

Calls 8

matchFunction · 0.85
wildcardsBeginMethod · 0.80
NameClass · 0.50
sizeMethod · 0.45
childMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected