GNOME Bugzilla – Bug 534208
[API] add gst_structure_get()
Last modified: 2009-06-10 08:41:21 UTC
Verily, some functions we should have: You have to #include <gobject/gvaluecollector.h> in the .c file for these. What think the people? gboolean gst_structure_get_valist (GstStructure *s, const char *first_field_name, va_list args) { const char *field_name = first_field_name; while (field_name) { GType t; const GValue *got = NULL; gchar *error; t = va_arg (args, GType); got = gst_structure_get_value (s, field_name); if (!got) return FALSE; if (G_VALUE_TYPE (got) != t) return FALSE; G_VALUE_LCOPY (got, args, 0, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error); g_free (error); return FALSE; } field_name = va_arg (args, const gchar*); } return TRUE; } gboolean gst_structure_get (GstStructure *s, const char *first_field_name, ...) { gboolean ret; va_list args; va_start (args, first_field_name); ret = gst_structure_get_valist (s, first_field_name, args); va_end (args); return ret; }
and don't forget the gst_structure_id_get variants!
Sounds like a good idea IMHO :)
Created attachment 136178 [details] [review] API: add gst_structure_{id}_get{_valist}() convenience functions How 'bout this then?
awesome, it should go in ASAP
Committed with slight changes after discussion on IRC (so that NULL return locations work as well): commit cdd47a37e9b11604ab626907d43aa510a0b5d614 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Mon Jun 8 23:43:16 2009 +0100 structure: add gst_structure_*_get*() vararg functions Add a bunch of vararg getter convenience functions to complement the vararg setter functions, and a basic unit test. Fixes #534208. API: gst_structure_get() API: gst_structure_id_get() API: gst_structure_get_valist() API: gst_structure_id_get_valist()