diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/include.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/include.cpp | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/sources/shiboken6/ApiExtractor/include.cpp b/sources/shiboken6/ApiExtractor/include.cpp index ea31d000a..aee6b7337 100644 --- a/sources/shiboken6/ApiExtractor/include.cpp +++ b/sources/shiboken6/ApiExtractor/include.cpp @@ -1,56 +1,44 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "include.h" #include "textstream.h" -#include <QDebug> -#include <QDir> -#include <QTextStream> -#include <QHash> + +#include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtCore/QHash> +#include <QtCore/QTextStream> + +#include "qtcompat.h" + +#include <algorithm> + +using namespace Qt::StringLiterals; QString Include::toString() const { if (m_type == IncludePath) - return QLatin1String("#include <") + m_name + QLatin1Char('>'); + return u"#include <"_s + m_name + u'>'; if (m_type == LocalPath) - return QLatin1String("#include \"") + m_name + QLatin1Char('"'); - return QLatin1String("import ") + m_name + QLatin1Char(';'); + return u"#include \""_s + m_name + u'"'; + return u"import "_s + m_name + u';'; } -size_t qHash(const Include& inc) +Qt::strong_ordering compareThreeWay(const Include &lhs, const Include &rhs) noexcept { - return qHash(inc.m_name); + if (lhs.m_type < rhs.m_type) + return Qt::strong_ordering::less; + if (lhs.m_type > rhs.m_type) + return Qt::strong_ordering::greater; + if (auto c = lhs.m_name.compare(rhs.m_name)) + return c < 0 ? Qt::strong_ordering::less : Qt::strong_ordering::greater; + return Qt::strong_ordering::equal; } -QTextStream& operator<<(QTextStream& out, const Include& include) +QTextStream& operator<<(QTextStream& out, const Include& g) { - if (include.isValid()) - out << include.toString() << Qt::endl; + if (g.isValid()) + out << g.toString() << Qt::endl; return out; } @@ -61,6 +49,19 @@ TextStream& operator<<(TextStream& out, const Include& include) return out; } +TextStream& operator<<(TextStream &out, const IncludeGroup& g) +{ + if (!g.includes.isEmpty()) { + if (!g.title.isEmpty()) + out << "\n// " << g.title << "\n"; + auto includes = g.includes; + std::sort(includes.begin(), includes.end()); + for (const Include &inc : std::as_const(includes)) + out << inc.toString() << '\n'; + } + return out; +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const Include &i) { |