MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / compare_rel

Method compare_rel

lib/pugixml/src/pugixml.cpp:9647–9716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9645 }
9646
9647 template <class Comp> static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp)
9648 {
9649 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
9650
9651 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
9652 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
9653 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
9654 {
9655 xpath_allocator_capture cr(stack.result);
9656
9657 xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all);
9658 xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all);
9659
9660 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
9661 {
9662 xpath_allocator_capture cri(stack.result);
9663
9664 double l = convert_string_to_number(string_value(*li, stack.result).c_str());
9665
9666 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
9667 {
9668 xpath_allocator_capture crii(stack.result);
9669
9670 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
9671 return true;
9672 }
9673 }
9674
9675 return false;
9676 }
9677 else if (lt != xpath_type_node_set && rt == xpath_type_node_set)
9678 {
9679 xpath_allocator_capture cr(stack.result);
9680
9681 double l = lhs->eval_number(c, stack);
9682 xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all);
9683
9684 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
9685 {
9686 xpath_allocator_capture cri(stack.result);
9687
9688 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
9689 return true;
9690 }
9691
9692 return false;
9693 }
9694 else if (lt == xpath_type_node_set && rt != xpath_type_node_set)
9695 {
9696 xpath_allocator_capture cr(stack.result);
9697
9698 xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all);
9699 double r = rhs->eval_number(c, stack);
9700
9701 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
9702 {
9703 xpath_allocator_capture cri(stack.result);
9704

Callers

nothing calls this directly

Calls 7

convert_string_to_numberFunction · 0.85
rettypeMethod · 0.80
eval_numberMethod · 0.80
eval_node_setMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected