diff options
author | Liang Qi <liang.qi@qt.io> | 2017-12-08 13:56:16 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-12-08 13:56:17 +0100 |
commit | 812bb236dd1622896b6a0ca9bbe1334a69855aa2 (patch) | |
tree | 94031beabaf904e2380740cec8951b3c1152203c /src/corelib/tools | |
parent | 79d78d814acad4e183e281aea9b131f396abe3fb (diff) | |
parent | 50117d738af526cbfbd5afa50b9a501acb0fb9ce (diff) |
Merge remote-tracking branch 'origin/5.10.0' into 5.10
Change-Id: I6dcf85067ec226136c207ea69ca9d66736c84db5
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qdatetime.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 7 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qstringalgorithms.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringiterator.qdoc | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringiterator_p.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringview.cpp | 26 | ||||
-rw-r--r-- | src/corelib/tools/qstringview.h | 40 |
9 files changed, 47 insertions, 42 deletions
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index adab47fc1f..3b741553d5 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -81,7 +81,7 @@ public: int daysInYear() const; int weekNumber(int *yearNum = Q_NULLPTR) const; -#if QT_DEPRECATED_SINCE(5, 11) && !defined QT_NO_TEXTDATE +#if QT_DEPRECATED_SINCE(5, 10) && !defined QT_NO_TEXTDATE QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName") static QString shortMonthName(int month, MonthNameType type = DateFormat); QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName") diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 6860cd6ef0..1a56418aaf 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1169,7 +1169,8 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, #if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found: QStringRef zoneName = input->midRef(pos, sect.used); Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0 - const QByteArray latinZone(zoneName.toLatin1()); + const QByteArray latinZone(zoneName == QLatin1String("Z") + ? QByteArray("UTC") : zoneName.toLatin1()); timeZone = QTimeZone(latinZone); tspec = timeZone.isValid() ? (QTimeZone::isTimeZoneIdAvailable(latinZone) @@ -1615,6 +1616,10 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, while (index > 0) { str.truncate(index); + if (str == QLatin1String("Z")) { + offset = 0; // "Zulu" time - a.k.a. UTC + break; + } QTimeZone zone(str.toLatin1()); if (zone.isValid()) { offset = zone.offsetFromUtc(when); diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 07bc1f8275..a072ea411c 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -576,7 +576,7 @@ int qt_repeatCount(QStringView s) if (s.isEmpty()) return 0; const QChar c = s.front(); - qssize_t j = 1; + qsizetype j = 1; while (j < s.size() && s.at(j) == c) ++j; return int(j); @@ -3443,7 +3443,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray bool dec = false; int decDigitCnt = 0; - for (qssize_t i = 0; i < str.size(); ++i) { + for (qsizetype i = 0; i < str.size(); ++i) { char c = digitToCLocale(str.at(i)); if (c >= '0' && c <= '9') { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7e8a8dca9a..4e59686d97 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -160,9 +160,9 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); -qssize_t QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW +qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW { - qssize_t result = 0; + qsizetype result = 0; #ifdef __SSE2__ // find the 16-byte alignment immediately prior or equal to str diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index 336da87468..aaa702301e 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -55,7 +55,7 @@ template <typename T> class QVector; namespace QtPrivate { -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; diff --git a/src/corelib/tools/qstringiterator.qdoc b/src/corelib/tools/qstringiterator.qdoc index 95c2247bc1..caec8803f3 100644 --- a/src/corelib/tools/qstringiterator.qdoc +++ b/src/corelib/tools/qstringiterator.qdoc @@ -120,7 +120,7 @@ */ /*! - \fn QStringIterator::QStringIterator(QStringView string, qssize_t idx) + \fn QStringIterator::QStringIterator(QStringView string, qsizetype idx) Constructs an iterator over the contents of \a string. The iterator will point before position \a idx in the string. diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/tools/qstringiterator_p.h index 8b1a6a1cd3..219589b6e4 100644 --- a/src/corelib/tools/qstringiterator_p.h +++ b/src/corelib/tools/qstringiterator_p.h @@ -62,7 +62,7 @@ class QStringIterator QString::const_iterator i, pos, e; Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value)); public: - explicit QStringIterator(QStringView string, qssize_t idx = 0) + explicit QStringIterator(QStringView string, qsizetype idx = 0) : i(string.begin()), pos(i + idx), e(string.end()) diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp index f510f44ce7..6321427a2d 100644 --- a/src/corelib/tools/qstringview.cpp +++ b/src/corelib/tools/qstringview.cpp @@ -131,9 +131,9 @@ QT_BEGIN_NAMESPACE /*! \typedef QStringView::size_type - Alias for qssize_t. Provided for compatibility with the STL. + Alias for qsizetype. Provided for compatibility with the STL. - Unlike other Qt classes, QStringView uses qssize_t as its \c size_type, to allow + Unlike other Qt classes, QStringView uses qsizetype as its \c size_type, to allow accepting data from \c{std::basic_string} without truncation. The Qt API functions, for example length(), return \c int, while the STL-compatible functions, for example size(), return \c size_type. @@ -224,7 +224,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView::QStringView(const Char *str, qssize_t len) + \fn QStringView::QStringView(const Char *str, qsizetype len) Constructs a string view on \a str with length \a len. @@ -486,7 +486,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qssize_t QStringView::size() const + \fn qsizetype QStringView::size() const Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same @@ -510,7 +510,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QChar QStringView::operator[](qssize_t n) const + \fn QChar QStringView::operator[](qsizetype n) const Returns the character at position \a n in this string view. @@ -520,7 +520,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QChar QStringView::at(qssize_t n) const + \fn QChar QStringView::at(qsizetype n) const Returns the character at position \a n in this string view. @@ -582,7 +582,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::mid(qssize_t start) const + \fn QStringView QStringView::mid(qsizetype start) const Returns the substring starting at position \a start in this object, and extending to the end of the string. @@ -593,7 +593,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::mid(qssize_t start, qssize_t length) const + \fn QStringView QStringView::mid(qsizetype start, qsizetype length) const \overload Returns the substring of length \a length starting at position @@ -606,7 +606,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::left(qssize_t length) const + \fn QStringView QStringView::left(qsizetype length) const Returns the substring of length \a length starting at position 0 in this object. @@ -617,7 +617,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::right(qssize_t length) const + \fn QStringView QStringView::right(qsizetype length) const Returns the substring of length \a length starting at position size() - \a length in this object. @@ -628,7 +628,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::chopped(qssize_t length) const + \fn QStringView QStringView::chopped(qsizetype length) const Returns the substring of length size() - \a length starting at the beginning of this object. @@ -641,7 +641,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QStringView::truncate(qssize_t length) + \fn void QStringView::truncate(qsizetype length) Truncates this string view to length \a length. @@ -653,7 +653,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QStringView::chop(qssize_t length) + \fn void QStringView::chop(qsizetype length) Truncates this string view by \a length characters. diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 6ff287a570..ef442e5b65 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -111,7 +111,7 @@ public: #endif typedef const QChar value_type; typedef std::ptrdiff_t difference_type; - typedef qssize_t size_type; + typedef qsizetype size_type; typedef value_type &reference; typedef value_type &const_reference; typedef value_type *pointer; @@ -139,17 +139,17 @@ private: using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type; template <typename Char, size_t N> - static Q_DECL_CONSTEXPR qssize_t lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW { - return qssize_t(N - 1); + return qsizetype(N - 1); } template <typename Char> - static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW { #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) if (__builtin_constant_p(*str)) { - qssize_t result = 0; + qsizetype result = 0; while (*str++) ++result; return result; @@ -157,7 +157,7 @@ private: #endif return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); } - static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW { return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); } @@ -175,7 +175,7 @@ public: : QStringView() {} template <typename Char, if_compatible_char<Char> = true> - Q_DECL_CONSTEXPR QStringView(const Char *str, qssize_t len) + Q_DECL_CONSTEXPR QStringView(const Char *str, qsizetype len) : m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)), m_data(castHelper(str)) {} @@ -205,20 +205,20 @@ public: #else template <typename String, if_compatible_qstring_like<String> = true> QStringView(const String &str) Q_DECL_NOTHROW - : QStringView(str.isNull() ? nullptr : str.data(), qssize_t(str.size())) {} + : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} #endif template <typename StdBasicString, if_compatible_string<StdBasicString> = true> QStringView(const StdBasicString &str) Q_DECL_NOTHROW - : QStringView(str.data(), qssize_t(str.size())) {} + : QStringView(str.data(), qsizetype(str.size())) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qssize_t size() const Q_DECL_NOTHROW { return m_size; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; } Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } // @@ -230,22 +230,22 @@ public: Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); } Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const; // defined in qvector.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qssize_t n) const { return (*this)[n]; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qsizetype n) const { return (*this)[n]; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos) const { return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QStringView(m_data + pos, m_size - pos); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos, qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos, qsizetype n) const { return Q_ASSERT(pos >= 0), Q_ASSERT(n >= 0), Q_ASSERT(pos + n <= size()), QStringView(m_data + pos, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data + m_size - n, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); } - Q_DECL_RELAXED_CONSTEXPR void truncate(qssize_t n) + Q_DECL_RELAXED_CONSTEXPR void truncate(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } - Q_DECL_RELAXED_CONSTEXPR void chop(qssize_t n) + Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } @@ -292,7 +292,7 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); } private: - qssize_t m_size; + qsizetype m_size; const storage_type *m_data; }; Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); |