Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtCore/qcollator.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0004 
0005 #ifndef QCOLLATOR_H
0006 #define QCOLLATOR_H
0007 
0008 #include <QtCore/qstring.h>
0009 #include <QtCore/qstringlist.h>
0010 #include <QtCore/qlocale.h>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 class QCollatorPrivate;
0015 class QCollatorSortKeyPrivate;
0016 
0017 class Q_CORE_EXPORT QCollatorSortKey
0018 {
0019     friend class QCollator;
0020 public:
0021     QCollatorSortKey(const QCollatorSortKey &other);
0022     ~QCollatorSortKey();
0023     QCollatorSortKey &operator=(const QCollatorSortKey &other);
0024     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCollatorSortKey)
0025     void swap(QCollatorSortKey &other) noexcept
0026     { d.swap(other.d); }
0027 
0028     int compare(const QCollatorSortKey &key) const;
0029     friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
0030     { return lhs.compare(rhs) < 0; }
0031 
0032 protected:
0033     QCollatorSortKey(QCollatorSortKeyPrivate*);
0034 
0035     QExplicitlySharedDataPointer<QCollatorSortKeyPrivate> d;
0036 
0037 private:
0038     QCollatorSortKey();
0039 };
0040 
0041 class Q_CORE_EXPORT QCollator
0042 {
0043 public:
0044     QCollator();
0045     explicit QCollator(const QLocale &locale);
0046     QCollator(const QCollator &);
0047     ~QCollator();
0048     QCollator &operator=(const QCollator &);
0049     QCollator(QCollator &&other) noexcept
0050         : d(other.d) { other.d = nullptr; }
0051     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCollator)
0052 
0053     void swap(QCollator &other) noexcept
0054     { qt_ptr_swap(d, other.d); }
0055 
0056     void setLocale(const QLocale &locale);
0057     QLocale locale() const;
0058 
0059     Qt::CaseSensitivity caseSensitivity() const;
0060     void setCaseSensitivity(Qt::CaseSensitivity cs);
0061 
0062     void setNumericMode(bool on);
0063     bool numericMode() const;
0064 
0065     void setIgnorePunctuation(bool on);
0066     bool ignorePunctuation() const;
0067 
0068     int compare(const QString &s1, const QString &s2) const
0069     { return compare(QStringView(s1), QStringView(s2)); }
0070 #if QT_CORE_REMOVED_SINCE(6, 4) && QT_POINTER_SIZE != 4
0071     int compare(const QChar *s1, int len1, const QChar *s2, int len2) const
0072     { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
0073 #endif
0074     int compare(const QChar *s1, qsizetype len1, const QChar *s2, qsizetype len2) const
0075     { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
0076 
0077     bool operator()(const QString &s1, const QString &s2) const
0078     { return compare(s1, s2) < 0; }
0079     int compare(QStringView s1, QStringView s2) const;
0080 
0081     bool operator()(QStringView s1, QStringView s2) const
0082     { return compare(s1, s2) < 0; }
0083 
0084     QCollatorSortKey sortKey(const QString &string) const;
0085 
0086     static int defaultCompare(QStringView s1, QStringView s2);
0087     static QCollatorSortKey defaultSortKey(QStringView key);
0088 
0089 private:
0090     QCollatorPrivate *d;
0091 
0092     void detach();
0093 };
0094 
0095 Q_DECLARE_SHARED(QCollatorSortKey)
0096 Q_DECLARE_SHARED(QCollator)
0097 
0098 QT_END_NAMESPACE
0099 
0100 #endif // QCOLLATOR_P_H