static GdaSet * make_options_set_from_string (const gchar *context, GdaSet *options) { GdaSet *expopt = NULL; GSList *list, *nlist = NULL; if (options) { for (list = options->holders; list; list = list->next) { GdaHolder *param = GDA_HOLDER (list->data); const GValue *cvalue; cvalue = gda_holder_get_attribute (param, context); if (!cvalue) continue; GdaHolder *nparam; const GValue *cvalue2; cvalue2 = gda_holder_get_value (param); nparam = gda_holder_new (G_VALUE_TYPE (cvalue2)); g_object_set ((GObject*) nparam, "id", g_value_get_string (cvalue), NULL); g_assert (gda_holder_set_value (nparam, cvalue2, NULL)); nlist = g_slist_append (nlist, nparam); } if (nlist) { expopt = gda_set_new (nlist); g_slist_free (nlist); } } return expopt; }
/* * run_context_push * * Add a new run context level below @context, running @stmt to create a data model */ static RunContext * run_context_push_with_stmt (GdaReportEngine *engine, RunContext *context, GdaConnection *cnc, GdaStatement *stmt, const gchar *stmt_name, GError **error) { GdaDataModel *model; GdaSet *plist; GdaStatement *lstmt; lstmt = rewrite_statement (engine, context, stmt, error); if (!lstmt) return NULL; g_assert (cnc); if (!gda_statement_get_parameters (lstmt, &plist, error)) { g_object_unref (lstmt); return NULL; } if (plist && !assign_parameters_values (engine, context, plist, error)) { g_object_unref (plist); g_object_unref (lstmt); return NULL; } model = gda_connection_statement_execute_select (cnc, lstmt, plist, error); if (plist) g_object_unref (plist); g_object_unref (lstmt); if (!model) return NULL; g_object_set_data_full (G_OBJECT (model), "name", g_strdup (stmt_name), g_free); /* add a parameter for the number of rows, attached to model */ GdaHolder *param; GValue *value; gchar *name; param = gda_holder_new (G_TYPE_INT); value = gda_value_new (G_TYPE_INT); g_value_set_int (value, gda_data_model_get_n_rows (model)); if (! gda_holder_set_value (param, value, error)) { g_object_unref (param); gda_value_free (value); return NULL; } gda_value_free (value); name = g_strdup_printf ("%s|?nrows", stmt_name); g_object_set_data_full (G_OBJECT (model), name, param, g_object_unref); g_free (name); /* create a new RunContext */ RunContext *ctx; ctx = g_new0 (RunContext, 1); ctx->stmt = NULL; ctx->cnc = cnc; ctx->parent = context; ctx->model = model; ctx->iter = gda_data_model_create_iter (model); /*g_print (">>>> PUSH CONTEXT %p\n", ctx);*/ return ctx; }