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

Method eval_number

UnitTests/TestApp/pugixml.cpp:8947–9067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8945 }
8946
8947 double eval_number(const xpath_context& c, const xpath_stack& stack)
8948 {
8949 switch (_type)
8950 {
8951 case ast_op_add: return _left->eval_number(c, stack) + _right->eval_number(c, stack);
8952
8953 case ast_op_subtract: return _left->eval_number(c, stack) - _right->eval_number(c, stack);
8954
8955 case ast_op_multiply: return _left->eval_number(c, stack) * _right->eval_number(c, stack);
8956
8957 case ast_op_divide: return _left->eval_number(c, stack) / _right->eval_number(c, stack);
8958
8959 case ast_op_mod: return fmod(_left->eval_number(c, stack), _right->eval_number(c, stack));
8960
8961 case ast_op_negate: return -_left->eval_number(c, stack);
8962
8963 case ast_number_constant: return _data.number;
8964
8965 case ast_func_last: return static_cast<double>(c.size);
8966
8967 case ast_func_position: return static_cast<double>(c.position);
8968
8969 case ast_func_count:
8970 {
8971 xpath_allocator_capture cr(stack.result);
8972
8973 return static_cast<double>(_left->eval_node_set(c, stack).size());
8974 }
8975
8976 case ast_func_string_length_0:
8977 {
8978 xpath_allocator_capture cr(stack.result);
8979
8980 return static_cast<double>(string_value(c.n, stack.result).length());
8981 }
8982
8983 case ast_func_string_length_1:
8984 {
8985 xpath_allocator_capture cr(stack.result);
8986
8987 return static_cast<double>(_left->eval_string(c, stack).length());
8988 }
8989
8990 case ast_func_number_0:
8991 {
8992 xpath_allocator_capture cr(stack.result);
8993
8994 return convert_string_to_number(string_value(c.n, stack.result).c_str());
8995 }
8996
8997 case ast_func_number_1: return _left->eval_number(c, stack);
8998
8999 case ast_func_sum:
9000 {
9001 xpath_allocator_capture cr(stack.result);
9002
9003 double r = 0;
9004

Callers 5

compare_eqMethod · 0.45
compare_relMethod · 0.45
apply_predicateMethod · 0.45
eval_stringMethod · 0.45
evaluate_numberMethod · 0.45

Calls 11

convert_string_to_numberFunction · 0.70
round_nearest_nzeroFunction · 0.70
sizeMethod · 0.45
eval_node_setMethod · 0.45
lengthMethod · 0.45
eval_stringMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
get_numberMethod · 0.45

Tested by

no test coverage detected