Add a g_value_cmp()
Submitted by Danielle Madeley
Link to original bug (#521916)
Description
I recently found myself wanting to compare two GValues that I knew were of the same type (I just didn't care which type they were) for equality. I couldn't find a function to do this. What I ended up doing was a big switch(G_VALUE_TYPE(&value)) full of comparison functions.
There is g_param_values_cmp(), but this requires you to create a GParamSpec (which I think requires you to know the type).
I propose the addition of a g_value_cmp() function with the prototype:
int g_value_cmp (GType type, GValue *value1, GValue *value2);
@type is the target type to do the comparison in (values will be transformed to this type), it is most likely going to be G_VALUE_TYPE(value1) or G_VALUE_TYPE(value2), but I don't see why it couldn't be anything else.
The function would return -1, 0 or 1 as per other cmp() functions.