[grilo] core: Replace grl_data_get_all_single_related_keys() functions



commit 0ead0a4fe37f64f8f0701ba837178df50a4b7f0f
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed Mar 30 09:51:20 2011 +0200

    core: Replace grl_data_get_all_single_related_keys() functions
    
    This name is quiet meaningless, so replace them by
    grl_data_get_single_values_for_key().
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 src/data/grl-data.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/data/grl-data.h |    8 +++++-
 2 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index 64bc7ad..4210047 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -856,7 +856,30 @@ GList *
 grl_data_get_all_single_related_keys (GrlData *data,
                                       GrlKeyID key)
 {
+  GRL_WARNING ("grl_data_get_all_single_related_keys() is deprecated. "
+               "Use instead grl_data_get_single_values_for_key()");
+
+  return grl_data_get_single_values_for_key (data, key);
+}
+
+/**
+ * grl_data_get_single_values_for_key:
+ * @data: a data
+ * @key: a metadata key
+ *
+ * Returns all non-%NULL values for @key from @data. This ignores related keys.
+ *
+ * Returns: (element-type GObject.Value) (transfer container): a #GList with
+ * values. Do not change or free the values. Free the list with #g_list_free.
+ */
+GList *
+grl_data_get_single_values_for_key (GrlData *data,
+                                    GrlKeyID key)
+{
+  GList *related_keys;
+  GList *values = NULL;
   GrlKeyID sample_key;
+  const GValue *v;
 
   g_return_val_if_fail (GRL_IS_DATA (data), NULL);
   g_return_val_if_fail (key, NULL);
@@ -866,7 +889,16 @@ grl_data_get_all_single_related_keys (GrlData *data,
     return NULL;
   }
 
-  return g_list_copy (g_hash_table_lookup (data->priv->data, sample_key));
+  related_keys = g_hash_table_lookup (data->priv->data, sample_key);
+  while (related_keys) {
+    v = grl_related_keys_get (related_keys->data, key);
+    if (v) {
+      values = g_list_prepend (values, (gpointer) v);
+    }
+    related_keys = g_list_next (related_keys);
+  }
+
+  return g_list_reverse (values);
 }
 
 /**
@@ -886,6 +918,27 @@ GList *
 grl_data_get_all_single_related_keys_string (GrlData *data,
                                              GrlKeyID key)
 {
+  GRL_WARNING ("grl_data_get_all_single_related_keys_string() is deprecated. "
+               "Use instead grl_data_get_single_values_for_key_string()");
+
+  return grl_data_get_single_values_for_key_string (data, key);
+}
+
+/**
+ * grl_data_get_single_values_for_key_string:
+ * @data: a data
+ * @key: a metadata key
+ *
+ * Returns all non-%NULL values for @key from @data. @key must have been
+ * registered as a string-type key. This ignores related keys.
+ *
+ * Returns: (element-type utf8) (transfer container): a #GList with values. Do
+ * not change or free the strings. Free the list with #g_list_free.
+ **/
+GList *
+grl_data_get_single_values_for_key_string (GrlData *data,
+                                           GrlKeyID key)
+{
   GList *list_strings = NULL;
   GList *list_values;
   GList *value;
@@ -900,7 +953,7 @@ grl_data_get_all_single_related_keys_string (GrlData *data,
     return NULL;
   }
 
-  list_values = grl_data_get_all_single_related_keys (data, key);
+  list_values = grl_data_get_single_values_for_key (data, key);
   for (value = list_values; value; value = g_list_next (value)) {
     string_value = g_value_get_string (value->data);
     if (string_value) {
diff --git a/src/data/grl-data.h b/src/data/grl-data.h
index 5a186b6..bc65d4c 100644
--- a/src/data/grl-data.h
+++ b/src/data/grl-data.h
@@ -142,9 +142,13 @@ guint grl_data_length (GrlData *data, GrlKeyID key);
 
 GrlRelatedKeys *grl_data_get_related_keys (GrlData *data, GrlKeyID key, guint index);
 
-GList *grl_data_get_all_single_related_keys (GrlData *data, GrlKeyID key);
+G_GNUC_DEPRECATED GList *grl_data_get_all_single_related_keys (GrlData *data, GrlKeyID key);
 
-GList *grl_data_get_all_single_related_keys_string (GrlData *data, GrlKeyID key);
+GList *grl_data_get_single_values_for_key (GrlData *data, GrlKeyID key);
+
+G_GNUC_DEPRECATED GList *grl_data_get_all_single_related_keys_string (GrlData *data, GrlKeyID key);
+
+GList *grl_data_get_single_values_for_key_string (GrlData *data, GrlKeyID key);
 
 void grl_data_remove_nth (GrlData *data, GrlKeyID key, guint index);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]