validate: Return a boolean when parsing an enum string
This commit is contained in:
parent
8852633dfc
commit
eb4a70a263
@ -484,18 +484,21 @@ gst_validate_utils_flags_from_str (GType type, const gchar * str_flags)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
gst_validate_utils_enum_from_str (GType type, const gchar * str_enum, guint * enum_value)
|
gst_validate_utils_enum_from_str (GType type, const gchar * str_enum, guint * enum_value)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
GEnumClass *class = g_type_class_ref (type);
|
GEnumClass *class = g_type_class_ref (type);
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
for (i = 0; i < class->n_values; i++) {
|
for (i = 0; i < class->n_values; i++) {
|
||||||
if (g_strrstr (str_enum, class->values[i].value_nick)) {
|
if (g_strrstr (str_enum, class->values[i].value_nick)) {
|
||||||
*enum_value = class->values[i].value;
|
*enum_value = class->values[i].value;
|
||||||
break;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_type_class_unref (class);
|
g_type_class_unref (class);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ gdouble gst_validate_utils_parse_expression (const gchar *expr,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar **error);
|
gchar **error);
|
||||||
guint gst_validate_utils_flags_from_str (GType type, const gchar * str_flags);
|
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,
|
const gchar * str_enum,
|
||||||
guint * enum_value);
|
guint * enum_value);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user