Esempio n. 1
0
		node_type binary_op::evaluate(evaluation_context errors) const {
			op_factory::bin_op_type impl = op_factory::get_binary_operator(op, left, right);
			if (is_int() || is_string()) {
				return impl->evaluate(errors, left, right);
			}
			errors->error("Missing operator implementation");
			return factory::create_false();
		}
Esempio n. 2
0
		node_type unary_op::evaluate(evaluation_context errors) const {
			op_factory::un_op_type impl = op_factory::get_unary_operator(op);
			value_type type = helpers::get_return_type(op, type_invalid);
			if (helpers::type_is_int(type)) {
				return impl->evaluate(errors, subject);
			}
			errors->error("Missing operator implementation");
			return factory::create_false();
		}
Esempio n. 3
0
		value_container float_value::get_value(evaluation_context errors, int type) const {
			if (type == type_float) {
				return value_container::create_float(value_, is_unsure_);
			}
			if (type == type_int) {
				return value_container::create_int(value_, is_unsure_);
			}
			errors->error("Failed to convert string to ?: " + strEx::s::xtos(value_));
			return value_container::create_nil();
		}
Esempio n. 4
0
node_type get_column_fun(const value_type, evaluation_context context, const node_type subject) {
	std::list<node_type> l = subject->get_list_value(context);
	if (l.size() != 1) {
		context->error("Invalid number of arguments for function");
		return factory::create_false();
	}
	node_type f = l.front();
	long long idx = f->get_int_value(context);
	logfile_filter::native_context* n_context = reinterpret_cast<logfile_filter::native_context*>(context.get());
	std::string value = n_context->get_object()->get_column(idx);
	return factory::create_string(value);
}
Esempio n. 5
0
		value_container string_value::get_value(evaluation_context errors, int type) const {
			if (type == type_float) {
				try {
					return value_container::create_float(strEx::s::stox<double>(value_), is_unsure_);
				} catch (const std::exception &) {
					errors->error("Failed to convert string to number: " + value_);
					return value_container::create_nil();
				}
			}
			if (type == type_int) {
				try {
					return value_container::create_int(strEx::s::stox<long long>(value_), is_unsure_);
				} catch (const std::exception &) {
					errors->error("Failed to convert string to number: " + value_);
					return value_container::create_nil();
				}
			}
			if (type == type_string) {
				return value_container::create_string(value_, is_unsure_);
			}
			errors->error("Failed to convert string to ?: " + value_);
			return value_container::create_nil();
		}
Esempio n. 6
0
node_type fun_convert_status(boost::shared_ptr<tasksched_filter::filter_obj> object, evaluation_context context, 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 factory::create_int(istat);
}