structure: API: Add gst_structure_id_has_field{,_typed}
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 2 Nov 2009 08:22:37 +0000 (09:22 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 2 Nov 2009 08:24:10 +0000 (09:24 +0100)
docs/gst/gstreamer-sections.txt
gst/gststructure.c
gst/gststructure.h
win32/common/libgstreamer.def

index f6798e6..67f73b7 100644 (file)
@@ -2054,6 +2054,8 @@ gst_structure_foreach
 gst_structure_n_fields
 gst_structure_has_field
 gst_structure_has_field_typed
+gst_structure_id_has_field
+gst_structure_id_has_field_typed
 gst_structure_get_boolean
 gst_structure_get_int
 gst_structure_get_uint
index b3ceb4e..e23f712 100644 (file)
@@ -1031,6 +1031,30 @@ gst_structure_map_in_place (GstStructure * structure,
 }
 
 /**
+ * gst_structure_id_has_field:
+ * @structure: a #GstStructure
+ * @field: #GQuark of the field name
+ *
+ * Check if @structure contains a field named @field.
+ *
+ * Returns: TRUE if the structure contains a field with the given name
+ *
+ * Since: 0.10.26
+ */
+gboolean
+gst_structure_id_has_field (const GstStructure * structure, GQuark field)
+{
+  GstStructureField *f;
+
+  g_return_val_if_fail (structure != NULL, FALSE);
+  g_return_val_if_fail (field != 0, FALSE);
+
+  f = gst_structure_id_get_field (structure, field);
+
+  return (f != NULL);
+}
+
+/**
  * gst_structure_has_field:
  * @structure: a #GstStructure
  * @fieldname: the name of a field
@@ -1043,14 +1067,39 @@ gboolean
 gst_structure_has_field (const GstStructure * structure,
     const gchar * fieldname)
 {
-  GstStructureField *field;
+  g_return_val_if_fail (structure != NULL, FALSE);
+  g_return_val_if_fail (fieldname != NULL, FALSE);
 
-  g_return_val_if_fail (structure != NULL, 0);
-  g_return_val_if_fail (fieldname != NULL, 0);
+  return gst_structure_id_has_field (structure,
+      g_quark_from_string (fieldname));
+}
 
-  field = gst_structure_get_field (structure, fieldname);
+/**
+ * gst_structure_id_has_field_typed:
+ * @structure: a #GstStructure
+ * @field: #GQuark of the field name
+ * @type: the type of a value
+ *
+ * Check if @structure contains a field named @field and with GType @type.
+ *
+ * Returns: TRUE if the structure contains a field with the given name and type
+ *
+ * Since: 0.10.16
+ */
+gboolean
+gst_structure_id_has_field_typed (const GstStructure * structure,
+    GQuark field, GType type)
+{
+  GstStructureField *f;
+
+  g_return_val_if_fail (structure != NULL, FALSE);
+  g_return_val_if_fail (field != 0, FALSE);
 
-  return (field != NULL);
+  f = gst_structure_id_get_field (structure, field);
+  if (f == NULL)
+    return FALSE;
+
+  return (G_VALUE_TYPE (&f->value) == type);
 }
 
 /**
@@ -1067,19 +1116,13 @@ gboolean
 gst_structure_has_field_typed (const GstStructure * structure,
     const gchar * fieldname, GType type)
 {
-  GstStructureField *field;
-
-  g_return_val_if_fail (structure != NULL, 0);
-  g_return_val_if_fail (fieldname != NULL, 0);
-
-  field = gst_structure_get_field (structure, fieldname);
-  if (field == NULL)
-    return FALSE;
+  g_return_val_if_fail (structure != NULL, FALSE);
+  g_return_val_if_fail (fieldname != NULL, FALSE);
 
-  return (G_VALUE_TYPE (&field->value) == type);
+  return gst_structure_id_has_field_typed (structure,
+      g_quark_from_string (fieldname), type);
 }
 
-
 /* utility functions */
 
 /**
index aa3aa5d..84e09aa 100644 (file)
@@ -172,6 +172,11 @@ gboolean                gst_structure_map_in_place         (GstStructure
                                                            gpointer                 user_data);
 gint                    gst_structure_n_fields             (const GstStructure      *structure);
 const gchar *           gst_structure_nth_field_name       (const GstStructure      *structure, guint index);
+gboolean                gst_structure_id_has_field         (const GstStructure      *structure,
+                                                           GQuark                   field);
+gboolean                gst_structure_id_has_field_typed   (const GstStructure      *structure,
+                                                           GQuark                   field,
+                                                           GType                    type);
 gboolean                gst_structure_has_field            (const GstStructure      *structure,
                                                            const gchar             *fieldname);
 gboolean                gst_structure_has_field_typed      (const GstStructure      *structure,
index fc88756..869b227 100644 (file)
@@ -905,6 +905,8 @@ EXPORTS
        gst_structure_id_get
        gst_structure_id_get_valist
        gst_structure_id_get_value
+       gst_structure_id_has_field
+       gst_structure_id_has_field_typed
        gst_structure_id_new
        gst_structure_id_set
        gst_structure_id_set_valist