]> saetta.ns0.it Git - libgdaex/commitdiff
Added functions DataModel::get_value_at and DataModel::get_field_value_at.
authorAndrea Zagli <azagli@libero.it>
Sun, 27 Sep 2020 07:53:07 +0000 (09:53 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 27 Sep 2020 07:53:07 +0000 (09:53 +0200)
src/gdaex.c
src/gdaex.h

index 2aed5d2a2f6ee5f87270a345739a3f97b44fac34..b2035c9ce43bf1ec8330f7b6fb4275968b217a35 100644 (file)
@@ -838,6 +838,18 @@ gdaex_data_model_is_empty (GdaDataModel *data_model)
                || gda_data_model_get_n_rows (data_model) < 1);
 }
 
+GValue
+*gdaex_data_model_get_field_value_at (GdaDataModel *data_model,
+                                      gint row,
+                                      const gchar *field_name)
+{
+       gint col;
+
+       col = gda_data_model_get_column_index (data_model, field_name);
+
+       return gdaex_data_model_get_value_at (data_model, row, col);
+}
+
 /**
  * gdaex_data_model_get_field_value_stringify_at:
  * @data_model: a #GdaDataModel object.
@@ -1136,6 +1148,30 @@ struct tm
        return value;
 }
 
+GValue
+*gdaex_data_model_get_value_at (GdaDataModel *data_model, gint row, gint col)
+{
+       const GValue *v;
+       GValue *ret;
+       GError *error;
+
+       error = NULL;
+
+       v = gda_data_model_get_value_at (data_model, col, row, &error);
+       if (v != NULL && error == NULL)
+               {
+                       ret = gda_value_new_null ();
+               }
+       else
+               {
+                       ret = g_new0 (GValue, 1);
+                       ret = g_value_init (ret, G_VALUE_TYPE (v));
+                       g_value_copy (v, ret);
+               }
+
+       return ret;
+}
+
 /**
  * gdaex_data_model_get_value_stringify_at:
  * @data_model: a #GdaDataModel object.
index 5779625daa05b9ff421d13ae082c6d096473e0b9..2030c1ea5b85da113ead3dec7726b157a3852f29 100644 (file)
@@ -96,6 +96,9 @@ GdaDataModel *gdaex_query (GdaEx *gdaex, const gchar *sql);
 
 gboolean gdaex_data_model_is_empty (GdaDataModel *data_model);
 
+GValue *gdaex_data_model_get_field_value_at (GdaDataModel *data_model,
+                                             gint row,
+                                             const gchar *field_name);
 gchar *gdaex_data_model_get_field_value_stringify_at (GdaDataModel *data_model,
                                                      gint row,
                                                      const gchar *field_name);
@@ -127,6 +130,9 @@ struct tm *gdaex_data_model_get_field_value_tm_at (GdaDataModel *data_model,
                                                    gint row,
                                                    const gchar *field_name);
 
+GValue *gdaex_data_model_get_value_at (GdaDataModel *data_model,
+                                       gint row,
+                                       gint col);
 gchar *gdaex_data_model_get_value_stringify_at (GdaDataModel *data_model,
                                                 gint row,
                                                 gint col);