From adf1b30934f2b2b92271955e7867a7b2620bc6b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Nov 2014 18:19:45 -0800 Subject: Make QVersionNumber private We're not ready. [ChangeLog][EDITORIAL] Remove all mentions of QVersionNumber. Change-Id: I03ad95992982eb3177f982c1eeddb6a6bc29336c Reviewed-by: Keith Gardner Reviewed-by: Lars Knoll --- src/corelib/tools/qversionnumber.cpp | 3 +- src/corelib/tools/qversionnumber.h | 201 --------------------- src/corelib/tools/qversionnumber_p.h | 201 +++++++++++++++++++++ src/testlib/qtest.h | 6 - src/testlib/qtestcase.cpp | 7 - .../tools/qversionnumber/qversionnumber.pro | 2 +- .../tools/qversionnumber/tst_qversionnumber.cpp | 2 +- 7 files changed, 205 insertions(+), 217 deletions(-) delete mode 100644 src/corelib/tools/qversionnumber.h create mode 100644 src/corelib/tools/qversionnumber_p.h diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp index 4d148249c0..3c8a9db086 100644 --- a/src/corelib/tools/qversionnumber.cpp +++ b/src/corelib/tools/qversionnumber.cpp @@ -40,7 +40,7 @@ ** ****************************************************************************/ -#include +#include #include #include #include @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE /*! \class QVersionNumber \inmodule QtCore + \internal \since 5.4 \brief The QVersionNumber class contains a version number with an arbitrary number of segments. diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h deleted file mode 100644 index a951b2f1a0..0000000000 --- a/src/corelib/tools/qversionnumber.h +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2014 Keith Gardner -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVERSIONNUMBER_H -#define QVERSIONNUMBER_H - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVersionNumber; -Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed = 0); - -#ifndef QT_NO_DATASTREAM -Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QVersionNumber &version); -Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version); -#endif - -class Q_CORE_EXPORT QVersionNumber -{ -public: - inline QVersionNumber() Q_DECL_NOTHROW - : m_segments() - {} - // compiler-generated copy/move ctor/assignment operators are ok - - inline explicit QVersionNumber(const QVector &seg) Q_DECL_NOTHROW - : m_segments(seg) - {} -#ifdef Q_COMPILER_RVALUE_REFS - inline explicit QVersionNumber(QVector &&seg) Q_DECL_NOTHROW - : m_segments(qMove(seg)) - {} -#endif -#ifdef Q_COMPILER_INITIALIZER_LISTS - inline QVersionNumber(std::initializer_list args) - : m_segments(args) - {} -#endif - - inline explicit QVersionNumber(int maj) - { m_segments.reserve(1); m_segments << maj; } - - inline explicit QVersionNumber(int maj, int min) - { m_segments.reserve(2); m_segments << maj << min; } - - inline explicit QVersionNumber(int maj, int min, int mic) - { m_segments.reserve(3); m_segments << maj << min << mic; } - - inline bool isNull() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return m_segments.isEmpty(); } - - inline bool isNormalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return isNull() || m_segments.last() != 0; } - - inline int majorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return segmentAt(0); } - - inline int minorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return segmentAt(1); } - - inline int microVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return segmentAt(2); } - -#if defined(Q_COMPILER_REF_QUALIFIERS) -# if defined(Q_CC_GNU) - // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 -# pragma push_macro("Q_REQUIRED_RESULT") -# undef Q_REQUIRED_RESULT -# define Q_REQUIRED_RESULT -# define Q_REQUIRED_RESULT_pushed -# endif - inline QVersionNumber normalized() const & Q_REQUIRED_RESULT - { - QVector segs(m_segments); - return normalizedImpl(segs); - } - - inline QVersionNumber normalized() && Q_REQUIRED_RESULT - { - return normalizedImpl(m_segments); - } - - inline QVector segments() const & Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return m_segments; } - - inline QVector segments() && Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return qMove(m_segments); } - -# ifdef Q_REQUIRED_RESULT_pushed -# pragma pop_macro("Q_REQUIRED_RESULT") -# endif -#else - inline QVersionNumber normalized() const Q_REQUIRED_RESULT - { - QVector segs(m_segments); - return normalizedImpl(segs); - } - - inline QVector segments() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return m_segments; } -#endif - - inline int segmentAt(int index) const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return (m_segments.size() > index) ? m_segments.at(index) : 0; } - - inline int segmentCount() const Q_DECL_NOTHROW Q_REQUIRED_RESULT - { return m_segments.size(); } - - bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - - static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - - static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT; - - QString toString() const Q_REQUIRED_RESULT; - static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = 0) Q_REQUIRED_RESULT; - -private: - static QVersionNumber normalizedImpl(QVector &segs) Q_REQUIRED_RESULT; - -#ifndef QT_NO_DATASTREAM - friend Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version); -#endif - friend Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed); - - QVector m_segments; -}; - -Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE); - -#ifndef QT_NO_DEBUG_STREAM -Q_CORE_EXPORT QDebug operator<<(QDebug, const QVersionNumber &version); -#endif - -Q_REQUIRED_RESULT inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) > 0; } - -Q_REQUIRED_RESULT inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) >= 0; } - -Q_REQUIRED_RESULT inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) < 0; } - -Q_REQUIRED_RESULT inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) <= 0; } - -Q_REQUIRED_RESULT inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) == 0; } - -Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW -{ return QVersionNumber::compare(lhs, rhs) != 0; } - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QVersionNumber) - -#endif //QVERSIONNUMBER_H diff --git a/src/corelib/tools/qversionnumber_p.h b/src/corelib/tools/qversionnumber_p.h new file mode 100644 index 0000000000..a951b2f1a0 --- /dev/null +++ b/src/corelib/tools/qversionnumber_p.h @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Keith Gardner +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVERSIONNUMBER_H +#define QVERSIONNUMBER_H + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVersionNumber; +Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed = 0); + +#ifndef QT_NO_DATASTREAM +Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QVersionNumber &version); +Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version); +#endif + +class Q_CORE_EXPORT QVersionNumber +{ +public: + inline QVersionNumber() Q_DECL_NOTHROW + : m_segments() + {} + // compiler-generated copy/move ctor/assignment operators are ok + + inline explicit QVersionNumber(const QVector &seg) Q_DECL_NOTHROW + : m_segments(seg) + {} +#ifdef Q_COMPILER_RVALUE_REFS + inline explicit QVersionNumber(QVector &&seg) Q_DECL_NOTHROW + : m_segments(qMove(seg)) + {} +#endif +#ifdef Q_COMPILER_INITIALIZER_LISTS + inline QVersionNumber(std::initializer_list args) + : m_segments(args) + {} +#endif + + inline explicit QVersionNumber(int maj) + { m_segments.reserve(1); m_segments << maj; } + + inline explicit QVersionNumber(int maj, int min) + { m_segments.reserve(2); m_segments << maj << min; } + + inline explicit QVersionNumber(int maj, int min, int mic) + { m_segments.reserve(3); m_segments << maj << min << mic; } + + inline bool isNull() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return m_segments.isEmpty(); } + + inline bool isNormalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return isNull() || m_segments.last() != 0; } + + inline int majorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return segmentAt(0); } + + inline int minorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return segmentAt(1); } + + inline int microVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return segmentAt(2); } + +#if defined(Q_COMPILER_REF_QUALIFIERS) +# if defined(Q_CC_GNU) + // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 +# pragma push_macro("Q_REQUIRED_RESULT") +# undef Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT_pushed +# endif + inline QVersionNumber normalized() const & Q_REQUIRED_RESULT + { + QVector segs(m_segments); + return normalizedImpl(segs); + } + + inline QVersionNumber normalized() && Q_REQUIRED_RESULT + { + return normalizedImpl(m_segments); + } + + inline QVector segments() const & Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return m_segments; } + + inline QVector segments() && Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return qMove(m_segments); } + +# ifdef Q_REQUIRED_RESULT_pushed +# pragma pop_macro("Q_REQUIRED_RESULT") +# endif +#else + inline QVersionNumber normalized() const Q_REQUIRED_RESULT + { + QVector segs(m_segments); + return normalizedImpl(segs); + } + + inline QVector segments() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return m_segments; } +#endif + + inline int segmentAt(int index) const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return (m_segments.size() > index) ? m_segments.at(index) : 0; } + + inline int segmentCount() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { return m_segments.size(); } + + bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + + static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW Q_REQUIRED_RESULT; + + static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT; + + QString toString() const Q_REQUIRED_RESULT; + static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = 0) Q_REQUIRED_RESULT; + +private: + static QVersionNumber normalizedImpl(QVector &segs) Q_REQUIRED_RESULT; + +#ifndef QT_NO_DATASTREAM + friend Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version); +#endif + friend Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed); + + QVector m_segments; +}; + +Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug, const QVersionNumber &version); +#endif + +Q_REQUIRED_RESULT inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) > 0; } + +Q_REQUIRED_RESULT inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) >= 0; } + +Q_REQUIRED_RESULT inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) < 0; } + +Q_REQUIRED_RESULT inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) <= 0; } + +Q_REQUIRED_RESULT inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) == 0; } + +Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +{ return QVersionNumber::compare(lhs, rhs) != 0; } + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QVersionNumber) + +#endif //QVERSIONNUMBER_H diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index d3443e7390..6298262958 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -164,11 +163,6 @@ template<> inline char *toString(const QVariant &v) return qstrdup(vstring.constData()); } -template<> inline char *toString(const QVersionNumber &version) -{ - return toString(version.toString()); -} - template<> inline bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 2d92b3f6bd..b174913eae 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1027,13 +1027,6 @@ QT_BEGIN_NAMESPACE Returns a textual representation of the given \a variant. */ -/*! - \fn char *QTest::toString(const QVersionNumber &version) - \overload - - Returns a textual representation of the given \a version. -*/ - /*! \fn void QTest::qWait(int ms) Waits for \a ms milliseconds. While waiting, events will be processed and diff --git a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro index 08ee0dd3d9..1e74d42bbd 100644 --- a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro +++ b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro @@ -1,4 +1,4 @@ CONFIG += testcase parallel_test TARGET = tst_qversionnumber -QT = core testlib +QT = core-private testlib SOURCES = tst_qversionnumber.cpp diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 18bc86620a..f97b8a4df8 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -33,7 +33,7 @@ ****************************************************************************/ #include -#include +#include class tst_QVersionNumber : public QObject { -- cgit v1.2.3