parsers::where::node_type calculate_free(boost::shared_ptr<filter_obj> object, parsers::where::evaluation_context context, parsers::where::node_type subject) { std::list<parsers::where::node_type> list = subject->get_list_value(context); if (list.size() != 2) { context->error("Invalid list value"); return parsers::where::factory::create_false(); } std::list<parsers::where::node_type>::const_iterator cit = list.begin(); parsers::where::node_type amount = *cit; ++cit; parsers::where::node_type unit = *cit; long long percentage = amount->get_int_value(context); long long value = (object->get_total()*percentage)/100; return parsers::where::factory::create_int(value); }
read_arg_type read_arguments(parsers::where::evaluation_context context, parsers::where::node_type subject, std::string default_unit) { std::list<parsers::where::node_type> list = subject->get_list_value(context); if (list.empty()) list.push_back(subject); long long value_int = 0; double value_float = 0.0; std::string unit = default_unit; std::list<parsers::where::node_type>::const_iterator cit; if (list.size() > 0) { cit = list.begin(); value_int = (*cit)->get_int_value(context); value_float = (*cit)->get_float_value(context); } if (list.size() > 1) { ++cit; unit = (*cit)->get_value(context, type_string).get_string(unit); } return boost::make_tuple(value_int, value_float, unit); }