| 10220 | } |
| 10221 | |
| 10222 | template <class T> xpath_node_set_raw step_do(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval, T v) |
| 10223 | { |
| 10224 | const axis_t axis = T::axis; |
| 10225 | const bool axis_reverse = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_preceding || axis == axis_preceding_sibling); |
| 10226 | const xpath_node_set::type_t axis_type = axis_reverse ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; |
| 10227 | |
| 10228 | bool once = |
| 10229 | (axis == axis_attribute && _test == nodetest_name) || |
| 10230 | (!_right && eval_once(axis_type, eval)) || |
| 10231 | // coverity[mixed_enums] |
| 10232 | (_right && !_right->_next && _right->_test == predicate_constant_one); |
| 10233 | |
| 10234 | xpath_node_set_raw ns; |
| 10235 | ns.set_type(axis_type); |
| 10236 | |
| 10237 | if (_left) |
| 10238 | { |
| 10239 | xpath_node_set_raw s = _left->eval_node_set(c, stack, nodeset_eval_all); |
| 10240 | |
| 10241 | // self axis preserves the original order |
| 10242 | if (axis == axis_self) ns.set_type(s.type()); |
| 10243 | |
| 10244 | for (const xpath_node* it = s.begin(); it != s.end(); ++it) |
| 10245 | { |
| 10246 | size_t size = ns.size(); |
| 10247 | |
| 10248 | // in general, all axes generate elements in a particular order, but there is no order guarantee if axis is applied to two nodes |
| 10249 | if (axis != axis_self && size != 0) ns.set_type(xpath_node_set::type_unsorted); |
| 10250 | |
| 10251 | step_fill(ns, *it, stack.result, once, v); |
| 10252 | if (_right) apply_predicates(ns, size, stack, eval); |
| 10253 | } |
| 10254 | } |
| 10255 | else |
| 10256 | { |
| 10257 | step_fill(ns, c.n, stack.result, once, v); |
| 10258 | if (_right) apply_predicates(ns, 0, stack, eval); |
| 10259 | } |
| 10260 | |
| 10261 | // child, attribute and self axes always generate unique set of nodes |
| 10262 | // for other axis, if the set stayed sorted, it stayed unique because the traversal algorithms do not visit the same node twice |
| 10263 | if (axis != axis_child && axis != axis_attribute && axis != axis_self && ns.type() == xpath_node_set::type_unsorted) |
| 10264 | ns.remove_duplicates(stack.temp); |
| 10265 | |
| 10266 | return ns; |
| 10267 | } |
| 10268 | |
| 10269 | public: |
| 10270 | xpath_ast_node(ast_type_t type, xpath_value_type rettype_, const char_t* value): |
nothing calls this directly
no test coverage detected