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

Method compare_rel

external/pugixml/pugixml.cpp:6879–6948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6877 }
6878
6879 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)
6880 {
6881 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
6882
6883 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
6884 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
6885 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
6886 {
6887 xpath_allocator_capture cr(stack.result);
6888
6889 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
6890 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
6891
6892 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
6893 {
6894 xpath_allocator_capture cri(stack.result);
6895
6896 double l = convert_string_to_number(string_value(*li, stack.result).c_str());
6897
6898 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
6899 {
6900 xpath_allocator_capture crii(stack.result);
6901
6902 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
6903 return true;
6904 }
6905 }
6906
6907 return false;
6908 }
6909 else if (lt != xpath_type_node_set && rt == xpath_type_node_set)
6910 {
6911 xpath_allocator_capture cr(stack.result);
6912
6913 double l = lhs->eval_number(c, stack);
6914 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
6915
6916 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
6917 {
6918 xpath_allocator_capture cri(stack.result);
6919
6920 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
6921 return true;
6922 }
6923
6924 return false;
6925 }
6926 else if (lt == xpath_type_node_set && rt != xpath_type_node_set)
6927 {
6928 xpath_allocator_capture cr(stack.result);
6929
6930 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
6931 double r = rhs->eval_number(c, stack);
6932
6933 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
6934 {
6935 xpath_allocator_capture cri(stack.result);
6936

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected