From 164392548e3e1c7526d4eef4896748ef5162cf2d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 22 Apr 2017 00:03:55 +0200 Subject: 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 #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 and , resp.). Change-Id: I7f8acf9c11bc1731266cd25c6eda9fb36723f364 Reviewed-by: Anton Kudryavtsev Reviewed-by: Edward Welbourne --- src/corelib/tools/qstringview.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/corelib/tools/qstringview.h') 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 +#ifndef QT_STRINGVIEW_LEVEL +# define QT_STRINGVIEW_LEVEL 1 #endif -#ifndef QSTRINGVIEW_H -#define QSTRINGVIEW_H +#include +#include +#include +#include #include 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 @@ -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(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 toUcs4() const; + Q_REQUIRED_RESULT inline QVector toUcs4() const; // defined in qvector.h Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qssize_t n) const { return (*this)[n]; } -- cgit v1.2.3