mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
validate: Return a boolean when parsing an enum string
This commit is contained in:
parent
8852633dfc
commit
eb4a70a263
2 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue