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

Method compare_eq

lib/pugixml/src/pugixml.cpp:9554–9640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9552 xpath_ast_node& operator=(const xpath_ast_node&);
9553
9554 template <class Comp> static bool compare_eq(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp)
9555 {
9556 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
9557
9558 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
9559 {
9560 if (lt == xpath_type_boolean || rt == xpath_type_boolean)
9561 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
9562 else if (lt == xpath_type_number || rt == xpath_type_number)
9563 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
9564 else if (lt == xpath_type_string || rt == xpath_type_string)
9565 {
9566 xpath_allocator_capture cr(stack.result);
9567
9568 xpath_string ls = lhs->eval_string(c, stack);
9569 xpath_string rs = rhs->eval_string(c, stack);
9570
9571 return comp(ls, rs);
9572 }
9573 }
9574 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
9575 {
9576 xpath_allocator_capture cr(stack.result);
9577
9578 xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all);
9579 xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all);
9580
9581 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
9582 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
9583 {
9584 xpath_allocator_capture cri(stack.result);
9585
9586 if (comp(string_value(*li, stack.result), string_value(*ri, stack.result)))
9587 return true;
9588 }
9589
9590 return false;
9591 }
9592 else
9593 {
9594 if (lt == xpath_type_node_set)
9595 {
9596 swap(lhs, rhs);
9597 swap(lt, rt);
9598 }
9599
9600 if (lt == xpath_type_boolean)
9601 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
9602 else if (lt == xpath_type_number)
9603 {
9604 xpath_allocator_capture cr(stack.result);
9605
9606 double l = lhs->eval_number(c, stack);
9607 xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all);
9608
9609 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
9610 {
9611 xpath_allocator_capture cri(stack.result);

Callers

nothing calls this directly

Calls 10

convert_string_to_numberFunction · 0.85
rettypeMethod · 0.80
eval_booleanMethod · 0.80
eval_numberMethod · 0.80
eval_stringMethod · 0.80
eval_node_setMethod · 0.80
swapFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected