MCPcopy Create free account
hub / github.com/WheretIB/nullc / compare_eq

Method compare_eq

external/pugixml/pugixml.cpp:6791–6877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6789 xpath_ast_node& operator=(const xpath_ast_node&);
6790
6791 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)
6792 {
6793 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
6794
6795 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
6796 {
6797 if (lt == xpath_type_boolean || rt == xpath_type_boolean)
6798 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
6799 else if (lt == xpath_type_number || rt == xpath_type_number)
6800 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
6801 else if (lt == xpath_type_string || rt == xpath_type_string)
6802 {
6803 xpath_allocator_capture cr(stack.result);
6804
6805 xpath_string ls = lhs->eval_string(c, stack);
6806 xpath_string rs = rhs->eval_string(c, stack);
6807
6808 return comp(ls, rs);
6809 }
6810 }
6811 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
6812 {
6813 xpath_allocator_capture cr(stack.result);
6814
6815 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
6816 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
6817
6818 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
6819 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
6820 {
6821 xpath_allocator_capture cri(stack.result);
6822
6823 if (comp(string_value(*li, stack.result), string_value(*ri, stack.result)))
6824 return true;
6825 }
6826
6827 return false;
6828 }
6829 else
6830 {
6831 if (lt == xpath_type_node_set)
6832 {
6833 swap(lhs, rhs);
6834 swap(lt, rt);
6835 }
6836
6837 if (lt == xpath_type_boolean)
6838 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
6839 else if (lt == xpath_type_number)
6840 {
6841 xpath_allocator_capture cr(stack.result);
6842
6843 double l = lhs->eval_number(c, stack);
6844 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
6845
6846 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
6847 {
6848 xpath_allocator_capture cri(stack.result);

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected