Пример #1
0
static void
arv_gc_converter_init (ArvGcConverter *gc_converter)
{
	gc_converter->formula_to = arv_evaluator_new (NULL);
	gc_converter->formula_from = arv_evaluator_new (NULL);
	gc_converter->value = NULL;
}
Пример #2
0
int
main (int argc, char **argv)
{
	ArvEvaluator *evaluator;
	GOptionContext *context;
	GError *error = NULL;
	int i;
	double value;

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, arv_option_entries, NULL);

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_option_context_free (context);
		g_print ("Option parsing failed: %s\n", error->message);
		g_error_free (error);
		return EXIT_FAILURE;
	}

	g_option_context_free (context);

	arv_debug_enable (arv_option_debug_domains);

	evaluator = arv_evaluator_new (NULL);

	arv_evaluator_set_double_variable (evaluator, "TDBL", 124.2);
	arv_evaluator_set_int64_variable (evaluator, "TINT", 3200);

	if (arv_option_expressions == NULL) {
		g_print ("Missing expression.\n");
		return EXIT_FAILURE;
	}

	for (i = 0; arv_option_expressions[i] != NULL; i++) {
		arv_evaluator_set_expression (evaluator, arv_option_expressions[i]);
		value = arv_evaluator_evaluate_as_double (evaluator, &error);

		if (error != NULL) {
			g_print ("Error in '%s': %s\n", arv_option_expressions[i],
				 error->message);
			g_error_free (error);
			error = NULL;
		} else
			g_print ("%s = %g\n", arv_option_expressions[i], value);
	}

	g_object_unref (evaluator);

	return EXIT_SUCCESS;
}
Пример #3
0
static void
arv_gc_swiss_knife_init (ArvGcSwissKnife *gc_swiss_knife)
{
	gc_swiss_knife->formula = arv_evaluator_new (NULL);
}