[libgda] GdaSet: removed holders field from public API
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaSet: removed holders field from public API
- Date: Wed, 27 Jun 2018 23:56:12 +0000 (UTC)
commit a259de89607728043eb7c589cd05bcb9a4b58a81
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Jun 27 16:51:51 2018 -0500
GdaSet: removed holders field from public API
Accessing holders list in a Set was a pain in GObject Introspection
libgda/gda-batch.c | 4 +-
libgda/gda-config.c | 10 ++---
libgda/gda-connection.c | 2 +-
libgda/gda-data-model-import.c | 4 +-
libgda/gda-data-model-iter.c | 22 +++++------
libgda/gda-data-pivot.c | 2 +-
libgda/gda-data-select.c | 28 +++++++-------
libgda/gda-meta-store.c | 4 +-
libgda/gda-server-operation.c | 2 +-
libgda/gda-server-provider.c | 2 +-
libgda/gda-set.c | 48 +++++++++++++++---------
libgda/gda-set.h | 4 +-
libgda/gda-tree-mgr-select.c | 8 ++--
libgda/gda-util.c | 2 +-
libgda/sqlite/virtual/gda-vconnection-hub.c | 4 +-
libgda/sqlite/virtual/gda-vprovider-data-model.c | 4 +-
tests/data-models/check_pmodel.c | 8 ++--
tests/providers/prov-test-util.c | 4 +-
tests/test-cnc-utils.c | 4 +-
tests/value-holders/common.c | 8 ++--
20 files changed, 93 insertions(+), 81 deletions(-)
---
diff --git a/libgda/gda-batch.c b/libgda/gda-batch.c
index 0869c6512..02abc87ef 100644
--- a/libgda/gda-batch.c
+++ b/libgda/gda-batch.c
@@ -427,7 +427,7 @@ gda_batch_get_parameters (GdaBatch *batch, GdaSet **out_params, GError **error)
return FALSE;
}
- if (tmpset && tmpset->holders) {
+ if (tmpset && gda_set_get_holders (tmpset)) {
if (!set) {
set = tmpset;
tmpset = NULL;
@@ -435,7 +435,7 @@ gda_batch_get_parameters (GdaBatch *batch, GdaSet **out_params, GError **error)
else {
/* merge @set and @tmp_set */
GSList *holders;
- for (holders = tmpset->holders; holders; holders = holders->next) {
+ for (holders = gda_set_get_holders (tmpset); holders; holders =
holders->next) {
GdaHolder *holder = (GdaHolder *) holders->data;
if (! gda_set_add_holder (set, holder)) {
GdaHolder *eholder = gda_set_get_holder (set,
gda_holder_get_id (holder));
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index f68c04d42..b0973eae7 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -1489,7 +1489,7 @@ gda_config_dsn_needs_authentication (const gchar *dsn_name)
gda_log_message (_("Provider '%s' not found"), info->provider);
return FALSE;
}
- if (pinfo->auth_params && pinfo->auth_params->holders)
+ if (pinfo->auth_params && gda_set_get_holders (pinfo->auth_params))
return TRUE;
else
return FALSE;
@@ -1781,12 +1781,12 @@ gda_config_list_providers (void)
if (info->dsn_params) {
GSList *params;
GString *string = g_string_new ("");
- for (params = info->dsn_params->holders;
+ for (params = gda_set_get_holders (info->dsn_params);
params; params = params->next) {
const gchar *id;
id = gda_holder_get_id (GDA_HOLDER (params->data));
- if (params != info->dsn_params->holders)
+ if (params != gda_set_get_holders (info->dsn_params))
g_string_append (string, ",\n");
g_string_append (string, id);
}
@@ -1799,12 +1799,12 @@ gda_config_list_providers (void)
if (info->auth_params) {
GSList *params;
GString *string = g_string_new ("");
- for (params = info->auth_params->holders;
+ for (params = gda_set_get_holders (info->auth_params);
params; params = params->next) {
const gchar *id;
id = gda_holder_get_id (GDA_HOLDER (params->data));
- if (params != info->auth_params->holders)
+ if (params != gda_set_get_holders (info->auth_params))
g_string_append (string, ",\n");
g_string_append (string, id);
}
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 9e2fef4d6..bf9185aa4 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -188,7 +188,7 @@ dump_exec_params (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params)
#ifdef GDA_DEBUG
g_print ("EVENT> COMMAND: parameters (on cnx %p) for statement [%s]\n", cnc, sql);
#endif
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
gchar *str;
const GValue *value;
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index f742c8611..852c40111 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -2012,7 +2012,7 @@ gda_data_model_import_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
g_object_get (G_OBJECT (iter), "update-model", &update_model, NULL);
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (plist = ((GdaSet *) iter)->holders, vlist = next_values;
+ for (plist = gda_set_get_holders (((GdaSet *) iter)), vlist = next_values;
plist && vlist;
plist = plist->next, vlist = vlist->next) {
GError *lerror = NULL;
@@ -2083,7 +2083,7 @@ gda_data_model_import_iter_prev (GdaDataModel *model, GdaDataModelIter *iter)
g_object_get (G_OBJECT (iter), "update-model", &update_model, NULL);
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (plist = ((GdaSet *) iter)->holders, vlist = imodel->priv->cursor_values;
+ for (plist = gda_set_get_holders (((GdaSet *) iter)), vlist = imodel->priv->cursor_values;
plist && vlist;
plist = plist->next, vlist = vlist->next) {
GError *lerror = NULL;
diff --git a/libgda/gda-data-model-iter.c b/libgda/gda-data-model-iter.c
index 945fffe49..12b32b11c 100644
--- a/libgda/gda-data-model-iter.c
+++ b/libgda/gda-data-model-iter.c
@@ -333,7 +333,7 @@ model_reset_cb (GdaDataModel *model, GdaDataModelIter *iter)
if (GDA_IS_DATA_PROXY (model))
nbcols = nbcols / 2;
- for (i = 0, list = ((GdaSet*) iter)->holders;
+ for (i = 0, list = gda_set_get_holders (((GdaSet*) iter));
(i < nbcols) && list;
i++, list = list->next) {
GdaColumn *col;
@@ -400,7 +400,7 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne
col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1;
if (col < 0)
g_set_error (&error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_COLUMN_OUT_OF_RANGE_ERROR,
- _("Column %d out of range (0-%d)"), col, g_slist_length
(paramlist->holders) - 1);
+ _("Column %d out of range (0-%d)"), col, g_slist_length
(gda_set_get_holders (paramlist)) - 1);
else if (GDA_DATA_MODEL_GET_CLASS ((GdaDataModel *)
iter->priv->data_model)->i_iter_set_value) {
if (! (GDA_DATA_MODEL_GET_CLASS ((GdaDataModel *)
iter->priv->data_model)->i_iter_set_value)
((GdaDataModel *) iter->priv->data_model, iter, col, nvalue, &error)) {
@@ -732,7 +732,7 @@ gda_data_model_iter_move_to_row_default (GdaDataModel *model, GdaDataModelIter *
/* actual sync. */
g_object_get (G_OBJECT (iter), "update-model", &update_model, NULL);
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (col = 0, list = ((GdaSet *) iter)->holders; list; col++, list = list->next) {
+ for (col = 0, list = gda_set_get_holders ((GdaSet *) iter); list; col++, list = list->next) {
const GValue *cvalue;
GError *lerror = NULL;
cvalue = gda_data_model_get_value_at (model, col, row, &lerror);
@@ -830,7 +830,7 @@ gda_data_model_iter_move_next_default (GdaDataModel *model, GdaDataModelIter *it
/* actual sync. */
g_object_get (G_OBJECT (iter), "update-model", &update_model, NULL);
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (col = 0, list = ((GdaSet *) iter)->holders; list; col++, list = list->next) {
+ for (col = 0, list = gda_set_get_holders ((GdaSet *) iter); list; col++, list = list->next) {
const GValue *cvalue;
GError *lerror = NULL;
cvalue = gda_data_model_get_value_at (model, col, row, &lerror);
@@ -929,7 +929,7 @@ gda_data_model_iter_move_prev_default (GdaDataModel *model, GdaDataModelIter *it
/* actual sync. */
g_object_get (G_OBJECT (iter), "update-model", &update_model, NULL);
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (col = 0, list = ((GdaSet *) iter)->holders; list; col++, list = list->next) {
+ for (col = 0, list = gda_set_get_holders ((GdaSet *) iter); list; col++, list = list->next) {
const GValue *cvalue;
GError *lerror = NULL;
cvalue = gda_data_model_get_value_at (model, col, row, &lerror);
@@ -980,7 +980,7 @@ gda_data_model_iter_invalidate_contents (GdaDataModelIter *iter)
g_return_if_fail (iter->priv);
iter->priv->keep_param_changes = TRUE;
- for (list = GDA_SET (iter)->holders; list; list = list->next)
+ for (list = gda_set_get_holders (GDA_SET (iter)); list; list = list->next)
gda_holder_force_invalid (GDA_HOLDER (list->data));
iter->priv->keep_param_changes = FALSE;
}
@@ -1020,9 +1020,9 @@ gda_data_model_iter_get_column_for_param (GdaDataModelIter *iter, GdaHolder *par
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), -1);
g_return_val_if_fail (iter->priv, -1);
g_return_val_if_fail (GDA_IS_HOLDER (param), -1);
- g_return_val_if_fail (g_slist_find (((GdaSet *) iter)->holders, param), -1);
+ g_return_val_if_fail (g_slist_find (gda_set_get_holders ((GdaSet *) iter), param), -1);
- return g_slist_index (((GdaSet *) iter)->holders, param);
+ return g_slist_index (gda_set_get_holders ((GdaSet *) iter), param);
}
/**
@@ -1061,7 +1061,7 @@ gda_data_model_iter_get_value_at (GdaDataModelIter *iter, gint col)
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), NULL);
g_return_val_if_fail (iter->priv, NULL);
- param = (GdaHolder *) g_slist_nth_data (((GdaSet *) iter)->holders, col);
+ param = (GdaHolder *) g_slist_nth_data (gda_set_get_holders ((GdaSet *) iter), col);
if (param) {
if (gda_holder_is_valid (param))
return gda_holder_get_value (param);
@@ -1092,7 +1092,7 @@ gda_data_model_iter_get_value_at_e (GdaDataModelIter *iter, gint col, GError **e
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), NULL);
g_return_val_if_fail (iter->priv, NULL);
- param = (GdaHolder *) g_slist_nth_data (((GdaSet *) iter)->holders, col);
+ param = (GdaHolder *) g_slist_nth_data (gda_set_get_holders ((GdaSet *) iter), col);
if (param) {
if (gda_holder_is_valid_e (param, error))
return gda_holder_get_value (param);
@@ -1127,7 +1127,7 @@ gda_data_model_iter_set_value_at (GdaDataModelIter *iter, gint col, const GValue
if (!holder) {
g_set_error (error, GDA_DATA_MODEL_ITER_ERROR, GDA_DATA_MODEL_ITER_COLUMN_OUT_OF_RANGE_ERROR,
_("Column %d out of range (0-%d)"), col,
- g_slist_length (((GdaSet *) iter)->holders) - 1);
+ g_slist_length (gda_set_get_holders ((GdaSet *) iter)) - 1);
return FALSE;
}
return gda_holder_set_value (holder, value, error);
diff --git a/libgda/gda-data-pivot.c b/libgda/gda-data-pivot.c
index 4dfaef066..8101a4503 100644
--- a/libgda/gda-data-pivot.c
+++ b/libgda/gda-data-pivot.c
@@ -1661,7 +1661,7 @@ gda_data_pivot_populate (GdaDataPivot *pivot, GError **error)
GdaColumn *column;
GdaHolder *holder;
column = gda_column_new ();
- holder = GDA_HOLDER (g_slist_nth_data (GDA_SET (iter)->holders, col));
+ holder = GDA_HOLDER (g_slist_nth_data (gda_set_get_holders (GDA_SET (iter)), col));
gda_column_set_name (column, gda_holder_get_id (holder));
gda_column_set_description (column, gda_holder_get_id (holder));
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index fba6c5fea..ea755fd0b 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -991,7 +991,7 @@ compute_modif_set (GdaDataSelect *model, GError **error)
gda_set_merge_with_set (model->priv->sh->modif_internals->modif_set, set);
GSList *list;
- for (list = set->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (set); list; list = list->next) {
GdaHolder *holder;
holder = gda_set_get_holder (model->priv->sh->modif_internals->modif_set,
gda_holder_get_id ((GdaHolder*) list->data));
@@ -1330,7 +1330,7 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
model->priv->sh->modif_internals->modif_set = gda_set_new (NULL);
}
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
GdaHolder *eholder;
eholder = gda_set_get_holder (model->priv->sh->modif_internals->modif_set,
@@ -1376,7 +1376,7 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
}
/* update GdaDataSelect's column attributes with GdaHolder's attributes */
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
gint num;
gboolean is_old;
@@ -2320,7 +2320,7 @@ update_iter (GdaDataSelect *imodel, GdaRow *prow)
if (update_model)
g_object_set (G_OBJECT (iter), "update-model", FALSE, NULL);
- for (i = 0, plist = GDA_SET (iter)->holders;
+ for (i = 0, plist = gda_set_get_holders (GDA_SET (iter));
plist;
i++, plist = plist->next) {
GValue *value;
@@ -2805,7 +2805,7 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
gboolean allok = TRUE;
/* overwrite old values with new values if some have been provided */
- for (list = imodel->priv->sh->modif_internals->modif_set->holders; list;
+ for (list = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); list;
list = list->next) {
GdaHolder *h = (GdaHolder*) list->data;
gint res;
@@ -2825,7 +2825,7 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
}
}
- for (list = dstmt->params->holders; list && allok; list = list->next) {
+ for (list = gda_set_get_holders (dstmt->params); list && allok; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
GdaHolder *eholder;
eholder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set,
@@ -2898,7 +2898,7 @@ gda_data_select_set_value_at (GdaDataModel *model, gint col, gint row, const GVa
/* invalidate all the imodel->priv->sh->modif_internals->modif_set's value holders */
GSList *list;
- for (list = imodel->priv->sh->modif_internals->modif_set->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); list; list =
list->next) {
GdaHolder *h = (GdaHolder*) list->data;
if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
gda_holder_force_invalid ((GdaHolder*) list->data);
@@ -2965,7 +2965,7 @@ gda_data_select_iter_set_value (GdaDataModel *model, GdaDataModelIter *iter, gi
/* invalidate all the imodel->priv->sh->modif_internals->modif_set's value holders */
GSList *list;
- for (list = imodel->priv->sh->modif_internals->modif_set->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); list; list =
list->next) {
GdaHolder *h = (GdaHolder*) list->data;
if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
gda_holder_force_invalid ((GdaHolder*) list->data);
@@ -3071,7 +3071,7 @@ gda_data_select_set_values (GdaDataModel *model, gint row, GList *values, GError
/* invalidate all the imodel->priv->sh->modif_internals->modif_set's value holders */
GSList *slist;
- for (slist = imodel->priv->sh->modif_internals->modif_set->holders; slist; slist = slist->next) {
+ for (slist = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); slist; slist =
slist->next) {
GdaHolder *h = (GdaHolder*) slist->data;
if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
gda_holder_force_invalid ((GdaHolder*) slist->data);
@@ -3256,14 +3256,14 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
compute_insert_select_params_mapping (dstmt->params, last_insert,
imodel->priv->sh->modif_internals->unique_row_condition);
if (imodel->priv->sh->modif_internals->insert_to_select_mapping) {
- for (list = dstmt->params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (dstmt->params); list; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
GdaHolder *eholder;
gint pos;
g_assert (param_name_to_int (gda_holder_get_id (holder), &pos, NULL));
- eholder = g_slist_nth_data (last_insert->holders,
+ eholder = g_slist_nth_data (gda_set_get_holders (last_insert),
imodel->priv->sh->modif_internals->insert_to_select_mapping[pos]);
if (!eholder ||
! gda_holder_set_value (holder, gda_holder_get_value (eholder),
error)) {
@@ -3454,7 +3454,7 @@ compute_insert_select_params_mapping (GdaSet *sel_params, GdaSet *ins_values, Gd
GSList *sel_list;
array = g_array_new (FALSE, TRUE, sizeof (gint));
- for (sel_list = sel_params->holders; sel_list; sel_list = sel_list->next) {
+ for (sel_list = gda_set_get_holders (sel_params); sel_list; sel_list = sel_list->next) {
CorrespData cdata;
const gchar *pid = gda_holder_get_id (GDA_HOLDER (sel_list->data));
cdata.hid = pid;
@@ -3478,7 +3478,7 @@ compute_insert_select_params_mapping (GdaSet *sel_params, GdaSet *ins_values, Gd
GSList *ins_list;
cdata.hid = NULL;
- for (ins_list = ins_values->holders; ins_list; ins_list = ins_list->next) {
+ for (ins_list = gda_set_get_holders (ins_values); ins_list; ins_list = ins_list->next) {
gchar *name;
g_object_get (G_OBJECT (ins_list->data), "name", &name, NULL);
if (!name) {
@@ -3779,7 +3779,7 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
to model->priv->sh->modif_internals->exec_set */
GSList *list;
if (model->priv->sh->ext_params) {
- for (list = model->priv->sh->ext_params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (model->priv->sh->ext_params); list; list = list->next) {
GdaHolder *h;
h = gda_set_get_holder (model->priv->sh->modif_internals->exec_set,
gda_holder_get_id (list->data));
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index d5cb03e2d..06d85c2f3 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -2996,7 +2996,7 @@ gda_meta_store_extract (GdaMetaStore *store, const gchar *select_sql, GError **e
}
va_end (ap);
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
if (!g_slist_find (params_set, list->data))
g_warning (_("No value set for parameter '%s'"),
gda_holder_get_id (GDA_HOLDER (list->data)));
@@ -3112,7 +3112,7 @@ gda_meta_store_extract_v (GdaMetaStore *store, const gchar *select_sql, GHashTab
}
}
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
if (!g_slist_find (params_set, list->data))
g_message (_("No value set for parameter '%s'"),
gda_holder_get_id (GDA_HOLDER (list->data)));
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index 0b23caaf1..cd3db1a95 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -1397,7 +1397,7 @@ node_save (GdaServerOperation *op, Node *opnode, xmlNodePtr parent)
complete_path = node_get_complete_path (op, opnode);
switch (opnode->type) {
case GDA_SERVER_OPERATION_NODE_PARAMLIST:
- for (list = opnode->d.plist->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (opnode->d.plist); list; list = list->next) {
gchar *path;
const GValue *value;
gchar *str;
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index 335ec87bd..74c67775d 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -995,7 +995,7 @@ gda_server_provider_create_operation (GdaServerProvider *provider, GdaConnection
xmlNodePtr top, node;
top = xmlNewNode (NULL, BAD_CAST "serv_op_data");
- for (list = options->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (options); list; list = list->next) {
const gchar *id;
gchar *str = NULL;
const GValue *value;
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 465139d36..23bdd0f5e 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -688,6 +688,8 @@ struct _GdaSetPrivate
GArray *holders_array;
gboolean read_only;
gboolean validate_changes;
+
+ GSList *holders; /* list of GdaHolder objects */
};
static void
@@ -724,7 +726,7 @@ gda_set_set_property (GObject *object,
if (set->priv->validate_changes != g_value_get_boolean (value)) {
GSList *list;
set->priv->validate_changes = g_value_get_boolean (value);
- for (list = set->holders; list; list = list->next) {
+ for (list = set->priv->holders; list; list = list->next) {
GdaHolder *holder = (GdaHolder*) list->data;
g_object_set ((GObject*) holder, "validate-changes",
set->priv->validate_changes, NULL);
@@ -1007,7 +1009,7 @@ static void
gda_set_init (GdaSet *set)
{
set->priv = g_new0 (GdaSetPrivate, 1);
- set->holders = NULL;
+ set->priv->holders = NULL;
set->nodes_list = NULL;
set->sources_list = NULL;
set->groups_list = NULL;
@@ -1081,7 +1083,7 @@ gda_set_copy (GdaSet *set)
GSList *list, *holders = NULL;
g_return_val_if_fail (GDA_IS_SET (set), NULL);
- for (list = set->holders; list; list = list->next)
+ for (list = set->priv->holders; list; list = list->next)
holders = g_slist_prepend (holders, gda_holder_copy (GDA_HOLDER (list->data)));
holders = g_slist_reverse (holders);
@@ -1606,7 +1608,7 @@ gda_set_remove_holder (GdaSet *set, GdaHolder *holder)
g_return_if_fail (GDA_IS_SET (set));
g_return_if_fail (set->priv);
- g_return_if_fail (g_slist_find (set->holders, holder));
+ g_return_if_fail (g_slist_find (set->priv->holders, holder));
if (set->priv->validate_changes)
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
@@ -1639,7 +1641,7 @@ gda_set_remove_holder (GdaSet *set, GdaHolder *holder)
}
set_remove_node (set, node);
- set->holders = g_slist_remove (set->holders, holder);
+ set->priv->holders = g_slist_remove (set->priv->holders, holder);
g_hash_table_remove (set->priv->holders_hash, gda_holder_get_id (holder));
if (set->priv->holders_array) {
g_array_free (set->priv->holders_array, TRUE);
@@ -1715,8 +1717,8 @@ gda_set_dispose (GObject *object)
set = GDA_SET (object);
/* free the holders list */
- if (set->holders) {
- for (list = set->holders; list; list = list->next) {
+ if (set->priv->holders) {
+ for (list = set->priv->holders; list; list = list->next) {
if (set->priv->validate_changes)
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (validate_change_holder_cb),
set);
@@ -1730,7 +1732,7 @@ gda_set_dispose (GObject *object)
}
g_object_unref (list->data);
}
- g_slist_free (set->holders);
+ g_slist_free (set->priv->holders);
}
if (set->priv->holders_hash) {
g_hash_table_destroy (set->priv->holders_hash);
@@ -1803,7 +1805,7 @@ compute_public_data (GdaSet *set)
/*
* Creation of the GdaSetNode structures
*/
- for (list = set->holders; list; list = list->next) {
+ for (list = set->priv->holders; list; list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
gint col;
node = gda_set_node_new (holder);
@@ -1928,7 +1930,7 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder)
const gchar *hid;
/*
- * try to find a similar holder in the set->holders:
+ * try to find a similar holder in the set->priv->holders:
* a holder B is similar to a holder A if it has the same ID
*/
hid = gda_holder_get_id (holder);
@@ -1940,7 +1942,7 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder)
similar = (GdaHolder*) g_hash_table_lookup (set->priv->holders_hash, hid);
if (!similar) {
/* really add @holder to the set */
- set->holders = g_slist_append (set->holders, holder);
+ set->priv->holders = g_slist_append (set->priv->holders, holder);
g_hash_table_insert (set->priv->holders_hash, (gchar*) hid, holder);
if (set->priv->holders_array) {
g_array_free (set->priv->holders_array, TRUE);
@@ -1994,7 +1996,7 @@ gda_set_merge_with_set (GdaSet *set, GdaSet *set_to_merge)
g_return_if_fail (GDA_IS_SET (set));
g_return_if_fail (set_to_merge && GDA_IS_SET (set_to_merge));
- for (holders = set_to_merge->holders; holders; holders = holders->next)
+ for (holders = set_to_merge->priv->holders; holders; holders = holders->next)
gda_set_real_add_holder (set, GDA_HOLDER (holders->data));
compute_public_data (set);
}
@@ -2036,7 +2038,7 @@ gda_set_is_valid (GdaSet *set, GError **error)
g_return_val_if_fail (GDA_IS_SET (set), FALSE);
g_return_val_if_fail (set->priv, FALSE);
- for (holders = set->holders; holders; holders = holders->next) {
+ for (holders = set->priv->holders; holders; holders = holders->next) {
if (!gda_holder_is_valid (GDA_HOLDER (holders->data))) {
g_set_error (error, GDA_SET_ERROR, GDA_SET_INVALID_ERROR,
"%s", _("One or more values are invalid"));
@@ -2105,8 +2107,8 @@ gda_set_get_nth_holder (GdaSet *set, gint pos)
if (! set->priv->holders_array) {
GSList *list;
set->priv->holders_array = g_array_sized_new (FALSE, FALSE, sizeof (GdaHolder*),
- g_slist_length (set->holders));
- for (list = set->holders; list; list = list->next)
+ g_slist_length (set->priv->holders));
+ for (list = set->priv->holders; list; list = list->next)
g_array_append_val (set->priv->holders_array, list->data);
}
if ((guint)pos >= set->priv->holders_array->len)
@@ -2115,6 +2117,16 @@ gda_set_get_nth_holder (GdaSet *set, gint pos)
return g_array_index (set->priv->holders_array, GdaHolder*, pos);
}
+/**
+ * gda_set_get_holders:
+ *
+ * Returns: (element-type Holder): a list of #GdaHolder objects in the set
+ */
+GSList*
+gda_set_get_holders (GdaSet *set) {
+ g_return_val_if_fail (GDA_IS_SET(set), NULL);
+ return set->priv->holders;
+}
/**
* gda_set_get_node:
* @set: a #GdaSet object
@@ -2134,7 +2146,7 @@ gda_set_get_node (GdaSet *set, GdaHolder *holder)
g_return_val_if_fail (set->priv, NULL);
g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);
/* FIXME: May is better to use holder's hash for better performance */
- g_return_val_if_fail (g_slist_find (set->holders, holder), NULL);
+ g_return_val_if_fail (g_slist_find (set->priv->holders, holder), NULL);
for (list = set->nodes_list; list && !retval; list = list->next) {
GdaHolder *node_holder;
@@ -2192,7 +2204,7 @@ gda_set_get_group (GdaSet *set, GdaHolder *holder)
g_return_val_if_fail (GDA_IS_SET (set), NULL);
g_return_val_if_fail (set->priv, NULL);
g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);
- g_return_val_if_fail (g_slist_find (set->holders, holder), NULL);
+ g_return_val_if_fail (g_slist_find (set->priv->holders, holder), NULL);
for (list = set->groups_list; list; list = list->next) {
retval = GDA_SET_GROUP (list->data);
@@ -2377,7 +2389,7 @@ void
gda_set_dump (GdaSet *set)
{
g_print ("=== GdaSet %p ===\n", set);
- g_slist_foreach (set->holders, (GFunc) holder_dump, NULL);
+ g_slist_foreach (set->priv->holders, (GFunc) holder_dump, NULL);
g_slist_foreach (set->nodes_list, (GFunc) set_node_dump, NULL);
g_slist_foreach (set->sources_list, (GFunc) set_source_dump, NULL);
g_slist_foreach (set->groups_list, (GFunc) set_group_dump, NULL);
diff --git a/libgda/gda-set.h b/libgda/gda-set.h
index fdcaaaf21..8f838b5c9 100644
--- a/libgda/gda-set.h
+++ b/libgda/gda-set.h
@@ -141,8 +141,7 @@ struct _GdaSet
GObject object;
GdaSetPrivate *priv;
- /*< public >*/
- GSList *holders; /* list of GdaHolder objects */
+ /*< public >*/
GSList *nodes_list; /* list of GdaSetNode */
GSList *sources_list; /* list of GdaSetSource */
GSList *groups_list; /* list of GdaSetGroup */
@@ -196,6 +195,7 @@ GdaSet *gda_set_new_from_spec_node (xmlNodePtr xml_spec, GError **er
gboolean gda_set_set_holder_value (GdaSet *set, GError **error, const gchar *holder_id, ...);
const GValue *gda_set_get_holder_value (GdaSet *set, const gchar *holder_id);
+GSList *gda_set_get_holders (GdaSet *set);
GdaHolder *gda_set_get_holder (GdaSet *set, const gchar *holder_id);
GdaHolder *gda_set_get_nth_holder (GdaSet *set, gint pos);
gboolean gda_set_add_holder (GdaSet *set, GdaHolder *holder);
diff --git a/libgda/gda-tree-mgr-select.c b/libgda/gda-tree-mgr-select.c
index b6b40f156..3620019b2 100644
--- a/libgda/gda-tree-mgr-select.c
+++ b/libgda/gda-tree-mgr-select.c
@@ -188,8 +188,8 @@ gda_tree_mgr_select_set_property (GObject *object,
if (lerror)
g_error_free (lerror);
}
- if (mgr->priv->priv_params && mgr->priv->priv_params->holders)
- mgr->priv->non_bound_params = g_slist_copy
(mgr->priv->priv_params->holders);
+ if (mgr->priv->priv_params && gda_set_get_holders (mgr->priv->priv_params))
+ mgr->priv->non_bound_params = g_slist_copy (gda_set_get_holders
(mgr->priv->priv_params));
}
break;
case PROP_PARAMS:
@@ -210,7 +210,7 @@ gda_tree_mgr_select_set_property (GObject *object,
GSList *non_bound_params = NULL;
g_slist_free (mgr->priv->non_bound_params);
- for (params = mgr->priv->priv_params->holders; params; params = params->next) {
+ for (params = gda_set_get_holders (mgr->priv->priv_params); params; params = params->next) {
GdaHolder *frh = GDA_HOLDER (params->data);
GdaHolder *toh = gda_set_get_holder (mgr->priv->params, gda_holder_get_id (frh));
if (toh) {
@@ -349,7 +349,7 @@ gda_tree_mgr_select_update_children (GdaTreeManager *manager, GdaTreeNode *node,
const GValue *cvalue;
GSList *iholders;
- for (iholders = GDA_SET (iter)->holders; iholders; iholders = iholders->next) {
+ for (iholders = gda_set_get_holders (GDA_SET (iter)); iholders; iholders = iholders->next) {
GdaHolder *holder = (GdaHolder*) iholders->data;
if (!gda_holder_is_valid (holder) || !(cvalue = gda_holder_get_value (holder))) {
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index 7d19d181e..c981321ea 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1543,7 +1543,7 @@ gda_rewrite_sql_statement_for_null_parameters (GdaSqlStatement *sqlst, GdaSet *p
if (!params)
return sqlst;
GSList *list;
- for (list = params->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (params); list; list = list->next) {
const GValue *cvalue;
cvalue = gda_holder_get_value ((GdaHolder*) list->data);
if (cvalue && (G_VALUE_TYPE (cvalue) == GDA_TYPE_NULL))
diff --git a/libgda/sqlite/virtual/gda-vconnection-hub.c b/libgda/sqlite/virtual/gda-vconnection-hub.c
index 62dd7d7ea..dfe93dc43 100644
--- a/libgda/sqlite/virtual/gda-vconnection-hub.c
+++ b/libgda/sqlite/virtual/gda-vconnection-hub.c
@@ -742,8 +742,8 @@ dict_table_create_model_func (GdaVconnectionDataModelSpec *spec, G_GNUC_UNUSED i
if (! gda_statement_get_parameters (stmt, ¶ms, NULL))
return NULL;
if (argc > 0) {
- g_assert (params && ((guint)argc == g_slist_length (params->holders)));
- for (i = 0, list = params->holders; i < argc; i++, list = list->next) {
+ g_assert (params && ((guint)argc == g_slist_length (gda_set_get_holders (params))));
+ for (i = 0, list = gda_set_get_holders (params); i < argc; i++, list = list->next) {
GdaHolder *holder = GDA_HOLDER (list->data);
GValue *value;
value = create_value_from_sqlite3_gvalue (gda_holder_get_g_type (holder),
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c
b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index ae8857555..ba6c01448 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -892,7 +892,7 @@ virtualNext (sqlite3_vtab_cursor *cur)
/* load data for row */
GSList *list;
gint count;
- for (count = 0, list = ((GdaSet*) data->iter)->holders; list;
+ for (count = 0, list = gda_set_get_holders ((GdaSet*) data->iter); list;
count++, list = list->next) {
GdaHolder *h = (GdaHolder*) list->data;
GError *lerror = NULL;
@@ -1501,7 +1501,7 @@ update_data_select_model (sqlite3_vtab *tab, gint optype, int nData, sqlite3_val
/* bind parameters */
GSList *list;
- for (list = vtable->td->modif_params [ptype]->holders; list; list = list->next) {
+ for (list = gda_set_get_holders (vtable->td->modif_params [ptype]); list; list = list->next) {
const gchar *id;
GdaHolder *holder = GDA_HOLDER (list->data);
gboolean holder_value_set = FALSE;
diff --git a/tests/data-models/check_pmodel.c b/tests/data-models/check_pmodel.c
index 98bfeaca3..c4f245169 100644
--- a/tests/data-models/check_pmodel.c
+++ b/tests/data-models/check_pmodel.c
@@ -1768,7 +1768,7 @@ test16 (GdaConnection *cnc)
g_object_unref (rerun);
/**/
- gda_holder_force_invalid (GDA_HOLDER (params->holders->data));
+ gda_holder_force_invalid (GDA_HOLDER (gda_set_get_holders (params)->data));
check_expected_signal (model, 'R', -1);
dump_data_model (model);
@@ -1809,7 +1809,7 @@ test17 (GdaConnection *cnc)
gint i, nullcol = -1;
GdaColumn *column;
GSList *list;
- for (i = 0, list = ((GdaSet*) iter)->holders;
+ for (i = 0, list = gda_set_get_holders ((GdaSet*) iter);
list;
i++, list = list->next) {
if (gda_holder_get_g_type ((GdaHolder *) list->data) == GDA_TYPE_NULL)
@@ -1845,13 +1845,13 @@ test17 (GdaConnection *cnc)
}
column = gda_data_model_describe_column (model, nullcol);
- if (gda_holder_get_g_type ((GdaHolder *) g_slist_nth_data (((GdaSet*) iter)->holders, nullcol)) !=
+ if (gda_holder_get_g_type ((GdaHolder *) g_slist_nth_data (gda_set_get_holders ((GdaSet*) iter),
nullcol)) !=
gda_column_get_g_type (column)) {
nfailed++;
#ifdef CHECK_EXTRA_INFO
g_print ("Iter's GdaHolder for column %d reports the '%s' type when it should be '%s'",
nullcol,
- g_type_name (gda_holder_get_g_type ((GdaHolder *) g_slist_nth_data (((GdaSet*)
iter)->holders,
+ g_type_name (gda_holder_get_g_type ((GdaHolder *) g_slist_nth_data
(gda_set_get_holders ((GdaSet*) iter),
nullcol))),
g_type_name (gda_column_get_g_type (column)));
#endif
diff --git a/tests/providers/prov-test-util.c b/tests/providers/prov-test-util.c
index ebc9c8575..1104b51fe 100644
--- a/tests/providers/prov-test-util.c
+++ b/tests/providers/prov-test-util.c
@@ -308,13 +308,13 @@ iter_is_correct (GdaDataModelIter *iter, GdaDataModel *ref_model)
g_object_get (G_OBJECT (iter), "current-row", &rownum, NULL);
cols = gda_data_model_get_n_columns (ref_model);
- if (cols != (gint)g_slist_length (GDA_SET (iter)->holders)) {
+ if (cols != (gint)g_slist_length (gda_set_get_holders (GDA_SET (iter)))) {
#ifdef CHECK_EXTRA_INFO
g_warning ("Number of columns in iter is not the same as for the referenced data model\n");
#endif
return FALSE;
}
- for (i = 0, list = GDA_SET (iter)->holders; i < cols; i++, list = list->next) {
+ for (i = 0, list = gda_set_get_holders (GDA_SET (iter)); i < cols; i++, list = list->next) {
const GValue *v1, *v2;
GError *lerror = NULL;
v1 = gda_holder_get_value (GDA_HOLDER (list->data));
diff --git a/tests/test-cnc-utils.c b/tests/test-cnc-utils.c
index b80cf9ce3..9a8b83993 100644
--- a/tests/test-cnc-utils.c
+++ b/tests/test-cnc-utils.c
@@ -133,7 +133,7 @@ test_cnc_open_connection (const gchar *provider, const gchar *dbname, GError **e
g_print ("Open connection string: %s\n", data.string->str);
gchar *auth_string = NULL;
- GSList *current = prov_info->auth_params->holders;
+ GSList *current = gda_set_get_holders (prov_info->auth_params);
while (current) {
GdaHolder *holder = (GdaHolder *) current->data;
@@ -457,7 +457,7 @@ test_cnc_load_data_from_file (GdaConnection *cnc, const gchar *table, const gcha
for (i = 0; i < nrows; i++) {
gint j;
GSList *list;
- for (list = params->holders, j = 0; list && (j < ncols); list = list->next, j++) {
+ for (list = gda_set_get_holders (params), j = 0; list && (j < ncols); list = list->next, j++)
{
const GValue *cvalue = gda_data_model_get_value_at (import, j, i, error);
if (!cvalue) {
gda_connection_rollback_transaction (cnc, NULL, NULL);
diff --git a/tests/value-holders/common.c b/tests/value-holders/common.c
index df3f7a5c5..87bb5cc16 100644
--- a/tests/value-holders/common.c
+++ b/tests/value-holders/common.c
@@ -108,10 +108,10 @@ tests_common_set_serialize (GdaSet *set)
string = g_string_new ("{");
/* holders */
- if (set->holders) {
+ if (gda_set_get_holders (set)) {
g_string_append (string, "\"holders\":[");
- for (list = set->holders; list; list = list->next) {
- if (list != set->holders)
+ for (list = gda_set_get_holders (set); list; list = list->next) {
+ if (list != gda_set_get_holders (set))
g_string_append_c (string, ',');
str = tests_common_holder_serialize (GDA_HOLDER (list->data));
g_string_append (string, str);
@@ -157,7 +157,7 @@ tests_common_set_serialize (GdaSet *set)
g_string_append_c (string, ',');
g_string_append_c (string, '{');
- g_string_append_printf (string, "\"holder\":%d", g_slist_index (set->holders,
gda_set_node_get_holder (node)));
+ g_string_append_printf (string, "\"holder\":%d", g_slist_index (gda_set_get_holders
(set), gda_set_node_get_holder (node)));
GdaDataModel *source_model;
source_model = gda_set_node_get_data_model (node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]