MCPcopy Create free account
hub / github.com/MyGUI/mygui / compare_eq

Method compare_eq

Tools/EditorFramework/pugixml.cpp:8153–8244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8151
8152 template<class Comp>
8153 static bool compare_eq(
8154 xpath_ast_node* lhs,
8155 xpath_ast_node* rhs,
8156 const xpath_context& c,
8157 const xpath_stack& stack,
8158 const Comp& comp)
8159 {
8160 xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
8161
8162 if (lt != xpath_type_node_set && rt != xpath_type_node_set)
8163 {
8164 if (lt == xpath_type_boolean || rt == xpath_type_boolean)
8165 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
8166 else if (lt == xpath_type_number || rt == xpath_type_number)
8167 return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack));
8168 else if (lt == xpath_type_string || rt == xpath_type_string)
8169 {
8170 xpath_allocator_capture cr(stack.result);
8171
8172 xpath_string ls = lhs->eval_string(c, stack);
8173 xpath_string rs = rhs->eval_string(c, stack);
8174
8175 return comp(ls, rs);
8176 }
8177 }
8178 else if (lt == xpath_type_node_set && rt == xpath_type_node_set)
8179 {
8180 xpath_allocator_capture cr(stack.result);
8181
8182 xpath_node_set_raw ls = lhs->eval_node_set(c, stack);
8183 xpath_node_set_raw rs = rhs->eval_node_set(c, stack);
8184
8185 for (const xpath_node* li = ls.begin(); li != ls.end(); ++li)
8186 for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri)
8187 {
8188 xpath_allocator_capture cri(stack.result);
8189
8190 if (comp(string_value(*li, stack.result), string_value(*ri, stack.result)))
8191 return true;
8192 }
8193
8194 return false;
8195 }
8196 else
8197 {
8198 if (lt == xpath_type_node_set)
8199 {
8200 swap(lhs, rhs);
8201 swap(lt, rt);
8202 }
8203
8204 if (lt == xpath_type_boolean)
8205 return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack));
8206 else if (lt == xpath_type_number)
8207 {
8208 xpath_allocator_capture cr(stack.result);
8209
8210 double l = lhs->eval_number(c, stack);

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected