Re: [Multi-valued V2 (grilo) 09/12] core: Add API to get single multivalued elements
- From: Iago Toral <itoral igalia com>
- To: <grilo-list gnome org>
- Subject: Re: [Multi-valued V2 (grilo) 09/12] core: Add API to get single multivalued elements
- Date: Tue, 01 Mar 2011 11:01:49 +0000
On Tue, 1 Mar 2011 10:50:28 +0100, "Juan A. Suarez Romero"
<jasuarez igalia com> wrote:
Add functions to retrieve a specific multivalued metadata key when
related keys
are of no interest.
Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
src/data/grl-data-multi.c | 91
+++++++++++++++++++++++++++++++++++++++++++++
src/data/grl-data-multi.h | 5 ++
2 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/src/data/grl-data-multi.c b/src/data/grl-data-multi.c
index 0d4e9d3..d595bff 100644
--- a/src/data/grl-data-multi.c
+++ b/src/data/grl-data-multi.c
@@ -292,6 +292,97 @@ grl_data_multi_get (GrlDataMulti *mdata,
}
/**
+ * grl_data_multi_get_all_single:
+ * @mdata: a multivalued data
+ * @key: a metadata key
+ *
+ * Returns all non-NULL values for specified key. This ignores
completely the
+ * related keys.
+ *
+ * Returns: (element-type GObject.Value) (transfer container): a
#GList with
+ * values. Free it with #g_list_free.
+ **/
+GList *
+grl_data_multi_get_all_single (GrlDataMulti *mdata,
+ GrlKeyID key)
+{
+ GList *list_values;
+ GList *result = NULL;
+ GValue *value;
+ GrlPluginRegistry *registry;
+ const GList *related_keys;
+
+ g_return_val_if_fail (GRL_IS_DATA_MULTI (mdata), NULL);
+
+ /* Get the representative element of key */
+ registry = grl_plugin_registry_get_default ();
+ related_keys = grl_plugin_registry_lookup_metadata_key_relation
(registry,
+
key);
+ if (!related_keys) {
+ GRL_WARNING ("Not found related keys");
Remember what I said about reviewing all the warning messages :).
In any case, since I saw you doing this kind of construction very
often, instead of "Not found related keys" it should be "Related keys
not found"to say it.
+ return result;
+ }
+
+ /* Get the first value */
+ value = (GValue *) grl_data_get (GRL_DATA (mdata), key);
+ if (value) {
+ result = g_list_prepend (result, value);
+ }
Iago
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]