From 1df45820d4ccbb67b9ad0f3eed167342f2917cf8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 23 Sep 2016 14:20:16 +0200 Subject: doc: Document two undocumented functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change provides missing documentation for two member functions of QString. QString QString::fromUtf16(const char16_t *str, int size) QString QString::fromUcs4(const char32_t *str, int size) Change-Id: I94a9437a457062e49e4457f5876e4d7c31fff24c Reviewed-by: André Hartmann Reviewed-by: Topi Reiniö --- src/corelib/tools/qstring.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b7f83e4b9d..645d213d82 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4818,6 +4818,39 @@ QString QString::fromUtf16(const ushort *unicode, int size) return QUtf16::convertToUnicode((const char *)unicode, size*2, 0); } +/*! + \fn QString QString::fromUtf16(const char16_t *str, int size) + \since 5.3 + + Returns a QString initialized with the first \a size characters + of the Unicode string \a str (ISO-10646-UTF-16 encoded). + + If \a size is -1 (default), \a str must be terminated + with a 0. + + This function checks for a Byte Order Mark (BOM). If it is missing, + host byte order is assumed. + + This function is slow compared to the other Unicode conversions. + Use QString(const QChar *, int) or QString(const QChar *) if possible. + + QString makes a deep copy of the Unicode data. + + \sa utf16(), setUtf16(), fromStdU16String() +*/ + +/*! + \fn QString QString::fromUcs4(const char32_t *str, int size) + \since 5.3 + + Returns a QString initialized with the first \a size characters + of the Unicode string \a str (ISO-10646-UCS-4 encoded). + + If \a size is -1 (default), \a str must be terminated + with a 0. + + \sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String() +*/ /*! \since 4.2 -- cgit v1.2.3 From dcedce51a62ae9519d8e85c004c2f93159be8751 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 1 Nov 2016 11:35:02 +0100 Subject: Include intrin.h header when using MSVC Fixes the build with MSVC15 Change-Id: I7f22938583775bb3f0767d50cf59a43cab95eede Reviewed-by: Friedemann Kleint --- src/corelib/tools/qalgorithms.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index ffa3082d5e..b22c5e219c 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -36,6 +36,10 @@ #include +#if defined(Q_CC_MSVC) && _MSC_VER > 1500 +#include +#endif + QT_BEGIN_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -- cgit v1.2.3 From ed7f77071dcca996a8c8147fd66344090666e60c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 5 Aug 2016 10:12:12 +0200 Subject: Replace custom type traits with std one's Remove most type traits from qtypetraits.h, but keep the custom implementation of is_signed/is_unsigned. This gets rid of BSD-3 licensed code from Google in a public header (hugh!). The custom implementations for is_signed/is_unsigned are kept because the implementations in gcc's standard headers do not work as we expect for enums - both is_signed and is_unsigned always returns false there - see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027 [ChangeLog][QtCore][General] Qt now relies on type traits from the C++ standard library. Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1 Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray_p.h | 3 +-- src/corelib/tools/qhash.h | 2 +- src/corelib/tools/qlist.h | 4 ++-- src/corelib/tools/qmap.h | 7 +++---- src/corelib/tools/qsharedpointer_impl.h | 2 +- src/corelib/tools/qstringalgorithms_p.h | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qbytearray_p.h b/src/corelib/tools/qbytearray_p.h index 0824611d99..6ebff739cd 100644 --- a/src/corelib/tools/qbytearray_p.h +++ b/src/corelib/tools/qbytearray_p.h @@ -52,14 +52,13 @@ // #include -#include #include "qtools_p.h" QT_BEGIN_NAMESPACE enum { // Define as enum to force inlining. Don't expose MaxAllocSize in a public header. - MaxByteArraySize = MaxAllocSize - sizeof(QtPrivate::remove_pointer::type) + MaxByteArraySize = MaxAllocSize - sizeof(std::remove_pointer::type) }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 6a2d7bdd11..d58c3c5733 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -764,7 +764,7 @@ Q_INLINE_TEMPLATE typename QHash::iterator QHash::insert(const K return iterator(createNode(h, akey, avalue, node)); } - if (!QtPrivate::is_same::value) + if (!std::is_same::value) (*node)->value = avalue; return iterator(*node); } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c7f27abdd6..c0a92aaa10 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -125,10 +125,10 @@ class QList { public: struct MemoryLayout - : QtPrivate::if_< + : std::conditional< QTypeInfo::isStatic || QTypeInfo::isLarge, QListData::IndirectLayout, - typename QtPrivate::if_< + typename std::conditional< sizeof(T) == sizeof(void*), QListData::ArrayCompatibleLayout, QListData::InlineWithPaddingLayout diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index baa10b7a95..96ce787446 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -44,7 +44,6 @@ #include #include #include -#include #ifdef Q_MAP_DEBUG #include @@ -130,15 +129,15 @@ struct QMapNode : public QMapNodeBase { callDestructorIfNecessary(key); callDestructorIfNecessary(value); - doDestroySubTree(QtPrivate::integral_constant::isComplex || QTypeInfo::isComplex>()); + doDestroySubTree(std::integral_constant::isComplex || QTypeInfo::isComplex>()); } QMapNode *lowerBound(const Key &key); QMapNode *upperBound(const Key &key); private: - void doDestroySubTree(QtPrivate::false_type) {} - void doDestroySubTree(QtPrivate::true_type) + void doDestroySubTree(std::false_type) {} + void doDestroySubTree(std::true_type) { if (left) leftNode()->destroySubTree(); diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index a0c22c9179..5738413bfb 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -464,7 +464,7 @@ private: template inline void enableSharedFromThis(const QEnableSharedFromThis *ptr) { - ptr->initializeFromSharedPointer(constCast::type>()); + ptr->initializeFromSharedPointer(constCast::type>()); } inline void enableSharedFromThis(...) {} diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h index d7127517e0..c5470bc7ad 100644 --- a/src/corelib/tools/qstringalgorithms_p.h +++ b/src/corelib/tools/qstringalgorithms_p.h @@ -60,8 +60,8 @@ template struct QStringAlgorithms { typedef typename StringType::value_type Char; typedef typename StringType::size_type size_type; - typedef typename QtPrivate::remove_cv::type NakedStringType; - static const bool isConst = QtPrivate::is_const::value; + typedef typename std::remove_cv::type NakedStringType; + static const bool isConst = std::is_const::value; static inline bool isSpace(char ch) { return ascii_isspace(ch); } static inline bool isSpace(QChar ch) { return ch.isSpace(); } -- cgit v1.2.3 From 9512d97c90cb5f989100b3ce7c258ea5fc2f7829 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 9 Nov 2016 14:36:08 +0100 Subject: Remove a few unnecessary recalculations of hash When we already have the hash-value we can give it to findNode to avoid recalculating it, and if don't need it later, we don't need to request it. Removes around 1% of qHash calls when running QtCreator. Change-Id: I0e5e61e26a407f4ac7e029a3ac13ddd553e4994b Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index d58c3c5733..66b5e75a1a 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -744,7 +744,7 @@ Q_INLINE_TEMPLATE T &QHash::operator[](const Key &akey) Node **node = findNode(akey, &h); if (*node == e) { if (d->willGrow()) - node = findNode(akey, &h); + node = findNode(akey, h); return createNode(h, akey, T(), node)->value; } return (*node)->value; @@ -760,7 +760,7 @@ Q_INLINE_TEMPLATE typename QHash::iterator QHash::insert(const K Node **node = findNode(akey, &h); if (*node == e) { if (d->willGrow()) - node = findNode(akey, &h); + node = findNode(akey, h); return iterator(createNode(h, akey, avalue, node)); } @@ -961,8 +961,7 @@ QPair::iterator, typename QHash::iterator> QHash< template QPair::const_iterator, typename QHash::const_iterator> QHash::equal_range(const Key &akey) const Q_DECL_NOTHROW { - uint h; - Node *node = *findNode(akey, &h); + Node *node = *findNode(akey); const_iterator firstIt = const_iterator(node); if (node != e) { -- cgit v1.2.3