diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/include.h')
-rw-r--r-- | sources/shiboken6/ApiExtractor/include.h | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/sources/shiboken6/ApiExtractor/include.h b/sources/shiboken6/ApiExtractor/include.h index 6b463a230..875a941f9 100644 --- a/sources/shiboken6/ApiExtractor/include.h +++ b/sources/shiboken6/ApiExtractor/include.h @@ -4,6 +4,8 @@ #ifndef INCLUDE_H #define INCLUDE_H +#include <QtCore/QtCompare> +#include <QtCore/QHashFunctions> #include <QtCore/QString> #include <QtCore/QList> @@ -42,23 +44,25 @@ public: QString toString() const; - bool operator<(const Include& other) const + int compare(const Include &rhs) const; + +private: + friend size_t qHash(Include &inc, size_t seed = 0) noexcept { - return m_name < other.m_name; + return qHashMulti(seed, inc.m_type, inc.m_name); } - - bool operator==(const Include& other) const + friend bool comparesEqual(const Include &lhs, const Include &rhs) noexcept { - return m_type == other.m_type && m_name == other.m_name; + return lhs.m_type == rhs.m_type && lhs.m_name == rhs.m_name; } + friend Qt::strong_ordering compareThreeWay(const Include &lhs, + const Include &rhs) noexcept; + Q_DECLARE_STRONGLY_ORDERED(Include) - friend size_t qHash(const Include&); - private: - IncludeType m_type = IncludePath; - QString m_name; + IncludeType m_type = IncludePath; + QString m_name; }; -size_t qHash(const Include& inc); QTextStream& operator<<(QTextStream& out, const Include& include); TextStream& operator<<(TextStream& out, const Include& include); #ifndef QT_NO_DEBUG_STREAM @@ -71,6 +75,17 @@ struct IncludeGroup { QString title; IncludeList includes; + + void append(const Include &include) + { + IncludeGroup::appendInclude(include, &includes); + } + + static void appendInclude(const Include &include, IncludeList *list) + { + if (include.isValid() && !list->contains(include)) + list->append(include); + } }; TextStream& operator<<(TextStream &out, const IncludeGroup& include); |