structure: API: Add gst_structure_id_has_field{,_typed}

This commit is contained in:
Sebastian Dröge 2009-11-02 09:22:37 +01:00
parent 0aff2c55b7
commit f9e3b72ff6
4 changed files with 67 additions and 15 deletions

View 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

View file

@ -1030,6 +1030,30 @@ gst_structure_map_in_place (GstStructure * structure,
return TRUE;
}
/**
* 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
@ -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;
return (field != NULL);
g_return_val_if_fail (structure != NULL, FALSE);
g_return_val_if_fail (field != 0, FALSE);
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, 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);
field = gst_structure_get_field (structure, fieldname);
if (field == NULL)
return FALSE;
return (G_VALUE_TYPE (&field->value) == type);
return gst_structure_id_has_field_typed (structure,
g_quark_from_string (fieldname), type);
}
/* utility functions */
/**

View 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,

View 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