summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringview.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-22 00:03:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-25 13:47:15 +0000
commit164392548e3e1c7526d4eef4896748ef5162cf2d (patch)
tree1da63115004bdfb3c9073b9e4b314254602e56ee /src/corelib/tools/qstringview.h
parent0cfcebb955099498c483a9dcc55863f833ba550f (diff)
Disentangle string-related headers
It's starting to hinder QStringView development (QString::append(QStringView), e.g.). - qbytearray.h includes qstring.h, but is included by qstring.h -> remove qstring.h include from qbytearray.h - the QStringLiteral definition is used from both qstring.h and qstringview.h -> extract into its own header, move QStringViewLiteral definition there, too - the qCompareStrings(), qConvertTo*() functions are used by QString and QStringView -> also extract into own header, included from qstring.h and qstringview.h - QStringView::toString() depends on QString, which depends on QStringView -> move QStringView::toString() definition to qstring.h, after the definition of QString -> move qstringview.h up to all the other includes in qstring.h This is starting to look like a DAG again, and allows to remove the unholy #ifndef QSTRING_H # include <qstring.h> #endif hack from qstringview.h. [ChangeLog][Potentially Source-Incompatible Changes][QByteArray] qbytearray.h no longer includes qstring.h. In particular, this means that in order to use QStringBuilder with QByteArray, you need to include both qbytearray.h and qstring.h now (or <QByteArray> and <QString>, resp.). Change-Id: I7f8acf9c11bc1731266cd25c6eda9fb36723f364 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/tools/qstringview.h')
-rw-r--r--src/corelib/tools/qstringview.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h
index 22f20796f4..527f1d48e7 100644
--- a/src/corelib/tools/qstringview.h
+++ b/src/corelib/tools/qstringview.h
@@ -36,24 +36,24 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef QSTRINGVIEW_H
+#define QSTRINGVIEW_H
-#ifndef QSTRING_H
-# include <QtCore/qstring.h>
+#ifndef QT_STRINGVIEW_LEVEL
+# define QT_STRINGVIEW_LEVEL 1
#endif
-#ifndef QSTRINGVIEW_H
-#define QSTRINGVIEW_H
+#include <QtCore/qchar.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qstringliteral.h>
+#include <QtCore/qstringalgorithms.h>
#include <string>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_UNICODE_LITERAL
-# ifndef QT_UNICODE_LITERAL
-# error "If you change QStringLiteral, please change QStringViewLiteral, too"
-# endif
-# define QStringViewLiteral(str) QStringView(QT_UNICODE_LITERAL(str))
-#endif
+class QString;
+class QStringRef;
namespace QtPrivate {
template <typename Char>
@@ -205,7 +205,7 @@ public:
QStringView(const StdBasicString &str) Q_DECL_NOTHROW
: QStringView(str.data(), qssize_t(str.size())) {}
- Q_REQUIRED_RESULT QString toString() const { return Q_ASSERT(size() == length()), QString(data(), length()); }
+ 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 const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); }
@@ -221,7 +221,7 @@ public:
Q_REQUIRED_RESULT QByteArray toLatin1() const { return qConvertToLatin1(*this); }
Q_REQUIRED_RESULT QByteArray toUtf8() const { return qConvertToUtf8(*this); }
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return qConvertToLocal8Bit(*this); }
- Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const;
+ 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]; }