mirror of
https://github.com/taglib/taglib.git
synced 2026-02-16 05:03:10 -05:00
Added some operators to compare String to string literals.
This commit is contained in:
@ -607,12 +607,39 @@ const TagLib::wchar &String::operator[](int i) const
|
||||
|
||||
bool String::operator==(const String &s) const
|
||||
{
|
||||
return d == s.d || d->data == s.d->data;
|
||||
return (d == s.d || d->data == s.d->data);
|
||||
}
|
||||
|
||||
bool String::operator!=(const String &s) const
|
||||
{
|
||||
return !operator==(s);
|
||||
return !(*this == s);
|
||||
}
|
||||
|
||||
bool String::operator==(const char *s) const
|
||||
{
|
||||
const wchar_t *p = toCWString();
|
||||
|
||||
while(*p != L'\0' || *s != '\0')
|
||||
{
|
||||
if(*p++ != static_cast<uchar>(*s++))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool String::operator!=(const char *s) const
|
||||
{
|
||||
return !(*this == s);
|
||||
}
|
||||
|
||||
bool String::operator==(const wchar_t *s) const
|
||||
{
|
||||
return (::wcscmp(toCWString(), s) == 0);
|
||||
}
|
||||
|
||||
bool String::operator!=(const wchar_t *s) const
|
||||
{
|
||||
return !(*this == s);
|
||||
}
|
||||
|
||||
String &String::operator+=(const String &s)
|
||||
|
||||
@ -397,6 +397,30 @@ namespace TagLib {
|
||||
*/
|
||||
bool operator!=(const String &s) const;
|
||||
|
||||
/*!
|
||||
* Compares each character of the String with each character of \a s and
|
||||
* returns true if the strings match.
|
||||
*/
|
||||
bool operator==(const char *s) const;
|
||||
|
||||
/*!
|
||||
* Compares each character of the String with each character of \a s and
|
||||
* returns false if the strings match.
|
||||
*/
|
||||
bool operator!=(const char *s) const;
|
||||
|
||||
/*!
|
||||
* Compares each character of the String with each character of \a s and
|
||||
* returns true if the strings match.
|
||||
*/
|
||||
bool operator==(const wchar_t *s) const;
|
||||
|
||||
/*!
|
||||
* Compares each character of the String with each character of \a s and
|
||||
* returns false if the strings match.
|
||||
*/
|
||||
bool operator!=(const wchar_t *s) const;
|
||||
|
||||
/*!
|
||||
* Appends \a s to the end of the String.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user