qom: introduce object_class_get_list_sorted

Unify half a dozen copies of very similar code (the only difference being
whether comparisons were case-sensitive) and use it also in Tricore,
which did not do any sorting of CPU model names.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2018-03-03 08:33:10 +01:00
parent 819fd4699c
commit 47c66009ab
8 changed files with 30 additions and 65 deletions

View file

@ -913,6 +913,17 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
GSList *object_class_get_list(const char *implements_type,
bool include_abstract);
/**
* object_class_get_list_sorted:
* @implements_type: The type to filter for, including its derivatives.
* @include_abstract: Whether to include abstract classes.
*
* Returns: A singly-linked list of the classes in alphabetical
* case-insensitive order.
*/
GSList *object_class_get_list_sorted(const char *implements_type,
bool include_abstract);
/**
* object_ref:
* @obj: the object