MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / compare_rel

Method compare_rel

src/include/pugixml.cpp:7501–7570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7499 }
7500
7501 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)
7502 {
7503 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
7504
7505 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
7506 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
7507 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
7508 {
7509 xpath_allocator_capture cr(stack.result);
7510
7511 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
7512 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
7513
7514 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
7515 {
7516 xpath_allocator_capture cri(stack.result);
7517
7518 double l = convert_string_to_number(string_value(*li, stack.result).c_str());
7519
7520 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
7521 {
7522 xpath_allocator_capture crii(stack.result);
7523
7524 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
7525 return true;
7526 }
7527 }
7528
7529 return false;
7530 }
7531 else if (lt != xpath_type_node_set && rt == xpath_type_node_set)
7532 {
7533 xpath_allocator_capture cr(stack.result);
7534
7535 double l = lhs->eval_number(c, stack);
7536 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
7537
7538 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
7539 {
7540 xpath_allocator_capture cri(stack.result);
7541
7542 if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str())))
7543 return true;
7544 }
7545
7546 return false;
7547 }
7548 else if (lt == xpath_type_node_set && rt != xpath_type_node_set)
7549 {
7550 xpath_allocator_capture cr(stack.result);
7551
7552 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
7553 double r = rhs->eval_number(c, stack);
7554
7555 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
7556 {
7557 xpath_allocator_capture cri(stack.result);
7558

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