mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
COMMON: Add comparison operators to U32String
Those operators just compare the numerical value of each character one by one. This is not idea, but this is better than nothing.
This commit is contained in:
parent
dd9256502a
commit
9fcc83c09d
@ -198,6 +198,34 @@ bool U32String::operator!=(const char *x) const {
|
||||
return !equals(x);
|
||||
}
|
||||
|
||||
bool U32String::operator<(const String &x) const {
|
||||
for (int i = 0 ; i < _size && i < x.size() ; ++i) {
|
||||
if (_str[i] < x[i])
|
||||
return true;
|
||||
else if (_str[i] > x[i])
|
||||
return false;
|
||||
}
|
||||
return (_size < x.size());
|
||||
}
|
||||
|
||||
bool U32String::operator<=(const String &x) const {
|
||||
return !operator>(x);
|
||||
}
|
||||
|
||||
bool U32String::operator>(const String &x) const {
|
||||
for (int i = 0 ; i < _size && i < x.size() ; ++i) {
|
||||
if (_str[i] > x[i])
|
||||
return true;
|
||||
else if (_str[i] < x[i])
|
||||
return false;
|
||||
}
|
||||
return (_size > x.size());
|
||||
}
|
||||
|
||||
bool U32String::operator>=(const String &x) const {
|
||||
return !operator<(x);
|
||||
}
|
||||
|
||||
bool U32String::equals(const U32String &x) const {
|
||||
if (this == &x || _str == x._str) {
|
||||
return true;
|
||||
|
@ -136,6 +136,11 @@ public:
|
||||
bool operator!=(const value_type *x) const;
|
||||
bool operator!=(const char *x) const;
|
||||
|
||||
bool operator<(const String &x) const;
|
||||
bool operator<=(const String &x) const;
|
||||
bool operator>(const String &x) const;
|
||||
bool operator>=(const String &x) const;
|
||||
|
||||
/**
|
||||
* Compares whether two U32String are the same based on memory comparison.
|
||||
* This does *not* do comparison based on canonical equivalence.
|
||||
|
Loading…
Reference in New Issue
Block a user