[Gambas-devel] Finding Variant

Benoît Minisini gambas at ...1...
Wed Aug 29 23:03:56 CEST 2012


Le 28/08/2012 17:04, Benoît Minisini a écrit :
> Le 28/08/2012 16:55, Tobias Boege a écrit :
>> Beno�t,
>>
>> is there an easy way to compare Variants? The Variant[] has no Find() and
>> the rest of the compare functions are specific to their datatypes which
>> could all live in one Variant. This is needed for the List.Find*()
>> functions so either "equal" or "not equal" will be enough for a result. (May
>> even memcmp() suffice for that?)
>>
>> Regards,
>> Tobi
>>
>
> No, the Variant comparison has only be implemented in operators. I will
> do that, and then I will add an API to compare two values.
>
> And no, memcmp() is not enough!
>

In revision #5099, you have a new API: GB.CompValue().

It takes two 'GB_VARIANT_VALUE *' 'a' and 'b', and returns 1 if 'a' is 
greater than 'b', -1 if 'b' is greater than 'a', and 0 if 'a' equals 'b'.

When 'a' and 'b' do not have the same type, it tries to do its best 
(conversion if they are not objects, NULL is always the lower value, and 
object is always greater than a non-object...).

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list