[Scummvm-devel] Make class String case insensitive by default?

Johannes Schickel lordhoto at gmail.com
Mon Jul 24 06:40:13 CEST 2006


Max Horn wrote:
>>   The subclass
>> proposal is better as it relies on the vtable field which is already
>> there.  Also it is less error prone as you don't add extra state to
>> the strings which needs to be maintained.
> 
> Aye. Though it doesn't solve the problem of how to deal with  
> comparing a "sensitive" string with an "insensitive one" (of course  
> you never said it would). In particular, if not done careful, then
>   a == b
> and
>   b == a
> might return different values, which would be a big no-no.
> 

I agree letting a == b and b == a not returning the same value would be
very bad.

>> Even so, I agree with Oystein that sensitivity should be a property of
>> the comparison, not the string.
> 
> So do I. Personally, I'd add
> 	bool equals(const String &x) const;
> 	bool equalsIgnoreCase(const String &x) const;
> 	bool compareTo(const String &x) const;
> 	bool compareToIgnoreCase(const String &x) const;
> methods (those names are taken from Java, and of course don't quite  
> fit in; this is just a quick example), as others already suggested.
> 

After all I read here this approach sounds really better. Still I think
that a solution which changes the behavior of '==' and other operators
would look nicer. I wouldn't mind if we use this way though.

// Johannes




More information about the Scummvm-devel mailing list