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
0002
0003
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 QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QCollatorSortKeyPrivate)
0017
0018 class Q_CORE_EXPORT QCollatorSortKey
0019 {
0020 friend class QCollator;
0021 public:
0022 QCollatorSortKey(const QCollatorSortKey &other);
0023 QCollatorSortKey(QCollatorSortKey &&other) noexcept = default;
0024 ~QCollatorSortKey();
0025 QCollatorSortKey &operator=(const QCollatorSortKey &other);
0026 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCollatorSortKey)
0027 void swap(QCollatorSortKey &other) noexcept
0028 { d.swap(other.d); }
0029
0030 int compare(const QCollatorSortKey &key) const;
0031 friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
0032 { return lhs.compare(rhs) < 0; }
0033
0034 protected:
0035 QCollatorSortKey(QCollatorSortKeyPrivate*);
0036
0037 QExplicitlySharedDataPointer<QCollatorSortKeyPrivate> d;
0038
0039 private:
0040 QCollatorSortKey();
0041 };
0042
0043 class Q_CORE_EXPORT QCollator
0044 {
0045 public:
0046 QCollator();
0047 explicit QCollator(const QLocale &locale);
0048 QCollator(const QCollator &);
0049 ~QCollator();
0050 QCollator &operator=(const QCollator &);
0051 QCollator(QCollator &&other) noexcept
0052 : d(other.d) { other.d = nullptr; }
0053 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCollator)
0054
0055 void swap(QCollator &other) noexcept
0056 { qt_ptr_swap(d, other.d); }
0057
0058 void setLocale(const QLocale &locale);
0059 QLocale locale() const;
0060
0061 Qt::CaseSensitivity caseSensitivity() const;
0062 void setCaseSensitivity(Qt::CaseSensitivity cs);
0063
0064 void setNumericMode(bool on);
0065 bool numericMode() const;
0066
0067 void setIgnorePunctuation(bool on);
0068 bool ignorePunctuation() const;
0069
0070 int compare(const QString &s1, const QString &s2) const
0071 { return compare(QStringView(s1), QStringView(s2)); }
0072 #if QT_CORE_REMOVED_SINCE(6, 4) && QT_POINTER_SIZE != 4
0073 int compare(const QChar *s1, int len1, const QChar *s2, int len2) const
0074 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
0075 #endif
0076 int compare(const QChar *s1, qsizetype len1, const QChar *s2, qsizetype len2) const
0077 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
0078
0079 bool operator()(const QString &s1, const QString &s2) const
0080 { return compare(s1, s2) < 0; }
0081 int compare(QStringView s1, QStringView s2) const;
0082
0083 bool operator()(QStringView s1, QStringView s2) const
0084 { return compare(s1, s2) < 0; }
0085
0086 QCollatorSortKey sortKey(const QString &string) const;
0087
0088 static int defaultCompare(QStringView s1, QStringView s2);
0089 static QCollatorSortKey defaultSortKey(QStringView key);
0090
0091 private:
0092 QCollatorPrivate *d;
0093
0094 void detach();
0095 };
0096
0097 Q_DECLARE_SHARED(QCollatorSortKey)
0098 Q_DECLARE_SHARED(QCollator)
0099
0100 QT_END_NAMESPACE
0101
0102 #endif