MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / first_element_by_path

Method first_element_by_path

Source/ThirdParty/pugixml/pugixml.cpp:5373–5418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5371#endif
5372
5373 PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const
5374 {
5375 xml_node found = *this; // Current search context.
5376
5377 if (!_root || !path_ || !path_[0]) return found;
5378
5379 if (path_[0] == delimiter)
5380 {
5381 // Absolute path; e.g. '/foo/bar'
5382 found = found.root();
5383 ++path_;
5384 }
5385
5386 const char_t* path_segment = path_;
5387
5388 while (*path_segment == delimiter) ++path_segment;
5389
5390 const char_t* path_segment_end = path_segment;
5391
5392 while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end;
5393
5394 if (path_segment == path_segment_end) return found;
5395
5396 const char_t* next_segment = path_segment_end;
5397
5398 while (*next_segment == delimiter) ++next_segment;
5399
5400 if (*path_segment == '.' && path_segment + 1 == path_segment_end)
5401 return found.first_element_by_path(next_segment, delimiter);
5402 else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end)
5403 return found.parent().first_element_by_path(next_segment, delimiter);
5404 else
5405 {
5406 for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling)
5407 {
5408 if (j->name && impl::strequalrange(j->name, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
5409 {
5410 xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter);
5411
5412 if (subsearch) return subsearch;
5413 }
5414 }
5415
5416 return xml_node();
5417 }
5418 }
5419
5420 PUGI__FN bool xml_node::traverse(xml_tree_walker& walker)
5421 {

Callers

nothing calls this directly

Calls 4

strequalrangeFunction · 0.85
xml_nodeClass · 0.85
rootMethod · 0.80
parentMethod · 0.80

Tested by

no test coverage detected