validate: Return a boolean when parsing an enum string

This commit is contained in:
Thibault Saunier 2014-04-25 18:26:50 +02:00
parent 8852633dfc
commit eb4a70a263
2 changed files with 6 additions and 3 deletions

View file

@ -484,18 +484,21 @@ gst_validate_utils_flags_from_str (GType type, const gchar * str_flags)
return flags;
}
void
gboolean
gst_validate_utils_enum_from_str (GType type, const gchar * str_enum, guint * enum_value)
{
guint i;
GEnumClass *class = g_type_class_ref (type);
gboolean ret = FALSE;
for (i = 0; i < class->n_values; i++) {
if (g_strrstr (str_enum, class->values[i].value_nick)) {
*enum_value = class->values[i].value;
break;
ret = TRUE;
}
}
g_type_class_unref (class);
return ret;
}

View file

@ -36,7 +36,7 @@ gdouble gst_validate_utils_parse_expression (const gchar *expr,
gpointer user_data,
gchar **error);
guint gst_validate_utils_flags_from_str (GType type, const gchar * str_flags);
void gst_validate_utils_enum_from_str (GType type,
gboolean gst_validate_utils_enum_from_str (GType type,
const gchar * str_enum,
guint * enum_value);
#endif