Package: glib

Function glib:variant-compare

Lambda List

glib:variant-compare (value1 value2)

Arguments

value1 -- a basic-typed g:variant instance
value2 -- a g:variant instance of the same type

Return Value

The integer with a negative value if a < b, zero if a = b, positive value if a > b.

Details

Compares value1 and value2. The variant types of value1 and value2 are :pointer only to allow use of this function with GTree, GPtrArray, etc. They must each be a g:variant instance.

Comparison is only defined for basic types, that is booleans, numbers, strings. For booleans, false is less than true. Numbers are ordered in the usual way. Strings are in ASCII lexographical order.

It is a programmer error to attempt to compare container values or two values that have types that are not exactly equal. For example, you cannot compare a 32-bit signed integer with a 32-bit unsigned integer. Also note that this function is not particularly well-behaved when it comes to comparison of doubles. In particular, the handling of incomparable values, like NaN, is undefined.

If you only require an equality comparison, the g:variant-equal function is more general.
 

See also

2024-11-20