mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
inline qstrcmp() function overloads
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
46d9359f9f
commit
beaf0af0f4
2 changed files with 23 additions and 37 deletions
|
@ -303,22 +303,6 @@ int qstrnicmp(const char *str1, const char *str2, uint len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
int qstrcmp(const QByteArray &str1, const char *str2)
|
||||
{
|
||||
return qstrcmp(str1.constData(), str2);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
int qstrcmp(const QByteArray &str1, const QByteArray &str2)
|
||||
{
|
||||
return qstrcmp(str1.constData(), str2.constData());
|
||||
}
|
||||
|
||||
// the CRC table below is created by the following piece of code
|
||||
#if 0
|
||||
static void createCRC16Table() // build CRC16 lookup table
|
||||
|
|
|
@ -70,12 +70,7 @@ inline uint qstrnlen(const char *str, uint maxlen)
|
|||
|
||||
Q_CORE_EXPORT char *qstrcpy(char *dst, const char *src);
|
||||
Q_CORE_EXPORT char *qstrncpy(char *dst, const char *src, uint len);
|
||||
|
||||
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2);
|
||||
Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const QByteArray &str2);
|
||||
Q_CORE_EXPORT int qstrcmp(const QByteArray &str1, const char *str2);
|
||||
static inline int qstrcmp(const char *str1, const QByteArray &str2)
|
||||
{ return -qstrcmp(str2, str1); }
|
||||
|
||||
inline int qstrncmp(const char *str1, const char *str2, uint len)
|
||||
{
|
||||
|
@ -441,39 +436,39 @@ inline bool QByteArray::contains(char c) const
|
|||
inline bool operator==(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); }
|
||||
inline bool operator==(const QByteArray &a1, const char *a2)
|
||||
{ return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); }
|
||||
{ return a2 ? qstrcmp(a1.constData(), a2) == 0 : a1.isEmpty(); }
|
||||
inline bool operator==(const char *a1, const QByteArray &a2)
|
||||
{ return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); }
|
||||
{ return a1 ? qstrcmp(a1, a2.constData()) == 0 : a2.isEmpty(); }
|
||||
inline bool operator!=(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return !(a1==a2); }
|
||||
inline bool operator!=(const QByteArray &a1, const char *a2)
|
||||
{ return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); }
|
||||
{ return a2 ? qstrcmp(a1.constData(), a2) != 0 : !a1.isEmpty(); }
|
||||
inline bool operator!=(const char *a1, const QByteArray &a2)
|
||||
{ return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); }
|
||||
{ return a1 ? qstrcmp(a1, a2.constData()) != 0 : !a2.isEmpty(); }
|
||||
inline bool operator<(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) < 0; }
|
||||
{ return qstrcmp(a1.constData(), a2.constData()) < 0; }
|
||||
inline bool operator<(const QByteArray &a1, const char *a2)
|
||||
{ return qstrcmp(a1, a2) < 0; }
|
||||
{ return qstrcmp(a1.constData(), a2) < 0; }
|
||||
inline bool operator<(const char *a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) < 0; }
|
||||
{ return qstrcmp(a1, a2.constData()) < 0; }
|
||||
inline bool operator<=(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) <= 0; }
|
||||
{ return qstrcmp(a1.constData(), a2.constData()) <= 0; }
|
||||
inline bool operator<=(const QByteArray &a1, const char *a2)
|
||||
{ return qstrcmp(a1, a2) <= 0; }
|
||||
{ return qstrcmp(a1.constData(), a2) <= 0; }
|
||||
inline bool operator<=(const char *a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) <= 0; }
|
||||
{ return qstrcmp(a1, a2.constData()) <= 0; }
|
||||
inline bool operator>(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) > 0; }
|
||||
{ return qstrcmp(a1.constData(), a2.constData()) > 0; }
|
||||
inline bool operator>(const QByteArray &a1, const char *a2)
|
||||
{ return qstrcmp(a1, a2) > 0; }
|
||||
{ return qstrcmp(a1.constData(), a2) > 0; }
|
||||
inline bool operator>(const char *a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) > 0; }
|
||||
{ return qstrcmp(a1, a2.constData()) > 0; }
|
||||
inline bool operator>=(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) >= 0; }
|
||||
{ return qstrcmp(a1.constData(), a2.constData()) >= 0; }
|
||||
inline bool operator>=(const QByteArray &a1, const char *a2)
|
||||
{ return qstrcmp(a1, a2) >= 0; }
|
||||
{ return qstrcmp(a1.constData(), a2) >= 0; }
|
||||
inline bool operator>=(const char *a1, const QByteArray &a2)
|
||||
{ return qstrcmp(a1, a2) >= 0; }
|
||||
{ return qstrcmp(a1, a2.constData()) >= 0; }
|
||||
inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
|
||||
{ return QByteArray(a1) += a2; }
|
||||
inline const QByteArray operator+(const QByteArray &a1, const char *a2)
|
||||
|
@ -534,6 +529,13 @@ inline QByteArray qFastUncompress(const QByteArray& data)
|
|||
Q_DECLARE_TYPEINFO(QByteArray, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_SHARED(QByteArray)
|
||||
|
||||
static inline int qstrcmp(const char *str1, const QByteArray &str2)
|
||||
{ return qstrcmp(str1, str2.constData()); }
|
||||
static inline int qstrcmp(const QByteArray &str1, const char *str2)
|
||||
{ return qstrcmp(str1.constData(), str2); }
|
||||
static inline int qstrcmp(const QByteArray &str1, const QByteArray &str2)
|
||||
{ return qstrcmp(str1.constData(), str2.constData()); }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
|
Loading…
Add table
Reference in a new issue