Example #1
0
parsers::where::node_type convert_type(boost::shared_ptr<filter_obj> object, parsers::where::evaluation_context context, parsers::where::node_type subject) {
	std::string keyword = subject->get_string_value(context);
	boost::to_lower(keyword);
	int type = do_convert_type(keyword);
	if (type == -1) {
		context->error("Failed to convert type: " + keyword);
		return parsers::where::factory::create_false();
	}
	return parsers::where::factory::create_int(type);
}
Example #2
0
	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);
	}
Example #3
0
			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);
			}
Example #4
0
parsers::where::node_type fun_convert_status(boost::shared_ptr<tasksched_filter::filter_obj> object, parsers::where::evaluation_context context, parsers::where::node_type subject) {
	std::string status = subject->get_string_value(context);
	long long istat = 0;
	if (object->is_new()) {
		if (status == "queued")
			istat = TASK_STATE_QUEUED;
		else if (status == "unknown")
			istat = TASK_STATE_UNKNOWN;
		else if (status == "ready")
			istat = TASK_STATE_READY;
		else if (status == "running")
			istat = TASK_STATE_RUNNING;
		else if (status == "disabled")
			istat = TASK_STATE_DISABLED;
		else 
			context->error("Failed to convert: " + status);
	} else {
		if (status == "ready")
			istat = SCHED_S_TASK_READY;
		else if (status == "running")
			istat = SCHED_S_TASK_RUNNING;
		else if (status == "not_scheduled")
			istat = SCHED_S_TASK_NOT_SCHEDULED;
		else if (status == "has_not_run")
			istat = SCHED_S_TASK_HAS_NOT_RUN;
		else if (status == "disabled")
			istat = SCHED_S_TASK_DISABLED;
		else if (status == "no_more_runs")
			istat = SCHED_S_TASK_NO_MORE_RUNS;
		else if (status == "no_valid_triggers")
			istat = SCHED_S_TASK_NO_VALID_TRIGGERS;
		else 
			context->error("Failed to convert: " + status);
	}
	return parsers::where::factory::create_int(istat);
}
Example #5
0
	parsers::where::node_type fun_convert_old_type(boost::shared_ptr<filter_obj> object, parsers::where::evaluation_context context, parsers::where::node_type subject) {
		return parsers::where::factory::create_int(convert_old_type(context, subject->get_string_value(context)));
	}
Example #6
0
	parsers::where::node_type parse_time(boost::shared_ptr<filter_obj> object, parsers::where::evaluation_context context, parsers::where::node_type subject) {
		return parsers::where::factory::create_int(strEx::stoui_as_time_sec(subject->get_string_value(context)));
	}