Move QStringRef and remains to Qt5Compat
Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
eb7d1cf098
commit
2766322de3
@ -60,8 +60,7 @@ Message::Message(const QString &body, const QStringList &headers)
|
|||||||
//! [custom type streaming operator]
|
//! [custom type streaming operator]
|
||||||
QDebug operator<<(QDebug dbg, const Message &message)
|
QDebug operator<<(QDebug dbg, const Message &message)
|
||||||
{
|
{
|
||||||
const QString body = message.body();
|
QList<QStringView> pieces = message.body().split(u"\r\n", Qt::SkipEmptyParts);
|
||||||
QList<QStringRef> pieces = body.splitRef(QLatin1String("\r\n"), Qt::SkipEmptyParts);
|
|
||||||
if (pieces.isEmpty())
|
if (pieces.isEmpty())
|
||||||
dbg.nospace() << "Message()";
|
dbg.nospace() << "Message()";
|
||||||
else if (pieces.size() == 1)
|
else if (pieces.size() == 1)
|
||||||
@ -73,7 +72,7 @@ QDebug operator<<(QDebug dbg, const Message &message)
|
|||||||
//! [custom type streaming operator]
|
//! [custom type streaming operator]
|
||||||
|
|
||||||
//! [getter functions]
|
//! [getter functions]
|
||||||
QString Message::body() const
|
QStringView Message::body() const
|
||||||
{
|
{
|
||||||
return m_body;
|
return m_body;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
Message(const QString &body, const QStringList &headers);
|
Message(const QString &body, const QStringList &headers);
|
||||||
|
|
||||||
QString body() const;
|
QStringView body() const;
|
||||||
QStringList headers() const;
|
QStringList headers() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -335,8 +335,8 @@ QToolBox *WidgetGallery::createTextToolBox()
|
|||||||
"How I wonder what you are!\n");
|
"How I wonder what you are!\n");
|
||||||
// Create centered/italic HTML rich text
|
// Create centered/italic HTML rich text
|
||||||
QString richText = QLatin1String("<html><head/><body><i>");
|
QString richText = QLatin1String("<html><head/><body><i>");
|
||||||
for (const auto &line : plainText.splitRef(QLatin1Char('\n')))
|
for (const auto &line : QStringView{ plainText }.split(QLatin1Char('\n')))
|
||||||
richText += QLatin1String("<center>") + line + QLatin1String("</center>");
|
richText += QString::fromLatin1("<center>%1</center>").arg(line);
|
||||||
richText += QLatin1String("</i></body></html>");
|
richText += QLatin1String("</i></body></html>");
|
||||||
|
|
||||||
auto textEdit = createWidget1<QTextEdit>(richText, "textEdit");
|
auto textEdit = createWidget1<QTextEdit>(richText, "textEdit");
|
||||||
|
@ -59,8 +59,8 @@ Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
|
|||||||
FlowLayout *lay = new FlowLayout;
|
FlowLayout *lay = new FlowLayout;
|
||||||
const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
|
const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
|
||||||
" I am bothered when I do not know others. (Confucius)"));
|
" I am bothered when I do not know others. (Confucius)"));
|
||||||
const QList<QStringRef> words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
|
const QList<QStringView> words = QStringView{ sentence }.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||||
for (const QStringRef &word : words) {
|
for (const QStringView &word : words) {
|
||||||
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
|
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
|
||||||
QLabel *label = new QLabel(word.toString());
|
QLabel *label = new QLabel(word.toString());
|
||||||
label->setFrameStyle(QFrame::Box | QFrame::Plain);
|
label->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||||
|
@ -151,15 +151,15 @@ static ParseCommandLineArgumentsResult
|
|||||||
return CommandLineArgumentsError;
|
return CommandLineArgumentsError;
|
||||||
if (++i == argumentCount)
|
if (++i == argumentCount)
|
||||||
return CommandLineArgumentsError;
|
return CommandLineArgumentsError;
|
||||||
const QString sizeStr = arguments.at(i);
|
const QStringView sizeStr{ arguments.at(i) };
|
||||||
const int idx = sizeStr.indexOf(QLatin1Char('x'));
|
const int idx = sizeStr.indexOf(QLatin1Char('x'));
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return CommandLineArgumentsError;
|
return CommandLineArgumentsError;
|
||||||
bool ok;
|
bool ok;
|
||||||
const int w = sizeStr.leftRef(idx).toInt(&ok);
|
const int w = sizeStr.left(idx).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return CommandLineArgumentsError;
|
return CommandLineArgumentsError;
|
||||||
const int h = sizeStr.midRef(idx + 1).toInt(&ok);
|
const int h = sizeStr.mid(idx + 1).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return CommandLineArgumentsError;
|
return CommandLineArgumentsError;
|
||||||
result->insert(name, QSize(w, h));
|
result->insert(name, QSize(w, h));
|
||||||
|
@ -381,7 +381,7 @@ void ArthurFrame::showSource()
|
|||||||
const QString html = QStringLiteral("<html><pre>") + contents + QStringLiteral("</pre></html>");
|
const QString html = QStringLiteral("<html><pre>") + contents + QStringLiteral("</pre></html>");
|
||||||
|
|
||||||
QTextBrowser *sourceViewer = new QTextBrowser;
|
QTextBrowser *sourceViewer = new QTextBrowser;
|
||||||
sourceViewer->setWindowTitle(tr("Source: %1").arg(m_sourceFileName.midRef(5)));
|
sourceViewer->setWindowTitle(tr("Source: %1").arg(QStringView{ m_sourceFileName }.mid(5)));
|
||||||
sourceViewer->setParent(this, Qt::Dialog);
|
sourceViewer->setParent(this, Qt::Dialog);
|
||||||
sourceViewer->setAttribute(Qt::WA_DeleteOnClose);
|
sourceViewer->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
sourceViewer->setLineWrapMode(QTextEdit::NoWrap);
|
sourceViewer->setLineWrapMode(QTextEdit::NoWrap);
|
||||||
|
@ -97,12 +97,12 @@ LanguageChooser::LanguageChooser(const QString &defaultLang, QWidget *parent)
|
|||||||
setWindowTitle("I18N");
|
setWindowTitle("I18N");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageChooser::languageMatch(const QString &lang, const QString &qmFile)
|
bool LanguageChooser::languageMatch(QStringView lang, QStringView qmFile)
|
||||||
{
|
{
|
||||||
//qmFile: i18n_xx.qm
|
//qmFile: i18n_xx.qm
|
||||||
const QString prefix = "i18n_";
|
const QStringView prefix{ u"i18n_" };
|
||||||
const int langTokenLength = 2; /*FIXME: is checking two chars enough?*/
|
const int langTokenLength = 2; /*FIXME: is checking two chars enough?*/
|
||||||
return qmFile.midRef(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.leftRef(langTokenLength);
|
return qmFile.mid(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.left(langTokenLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageChooser::eventFilter(QObject *object, QEvent *event)
|
bool LanguageChooser::eventFilter(QObject *object, QEvent *event)
|
||||||
|
@ -83,7 +83,7 @@ private:
|
|||||||
static QStringList findQmFiles();
|
static QStringList findQmFiles();
|
||||||
static QString languageName(const QString &qmFile);
|
static QString languageName(const QString &qmFile);
|
||||||
static QColor colorForLanguage(const QString &language);
|
static QColor colorForLanguage(const QString &language);
|
||||||
static bool languageMatch(const QString &lang, const QString &qmFile);
|
static bool languageMatch(QStringView lang, QStringView qmFile);
|
||||||
|
|
||||||
QGroupBox *groupBox;
|
QGroupBox *groupBox;
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
|
@ -87,9 +87,7 @@ public:
|
|||||||
void lastIndexOfFunction();
|
void lastIndexOfFunction();
|
||||||
void leftFunction();
|
void leftFunction();
|
||||||
void leftJustifiedFunction();
|
void leftJustifiedFunction();
|
||||||
void leftRefFunction();
|
|
||||||
void midFunction();
|
void midFunction();
|
||||||
void midRefFunction();
|
|
||||||
void numberFunction();
|
void numberFunction();
|
||||||
|
|
||||||
void prependFunction();
|
void prependFunction();
|
||||||
@ -99,7 +97,6 @@ public:
|
|||||||
void resizeFunction();
|
void resizeFunction();
|
||||||
void rightFunction();
|
void rightFunction();
|
||||||
void rightJustifiedFunction();
|
void rightJustifiedFunction();
|
||||||
void rightRefFunction();
|
|
||||||
void sectionFunction();
|
void sectionFunction();
|
||||||
void setNumFunction();
|
void setNumFunction();
|
||||||
void simplifiedFunction();
|
void simplifiedFunction();
|
||||||
@ -959,31 +956,6 @@ void Widget::arrayOperator()
|
|||||||
//! [85]
|
//! [85]
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::midRefFunction()
|
|
||||||
{
|
|
||||||
//! [midRef]
|
|
||||||
QString x = "Nine pineapples";
|
|
||||||
QStringRef y = x.midRef(5, 4); // y == "pine"
|
|
||||||
QStringRef z = x.midRef(5); // z == "pineapples"
|
|
||||||
//! [midRef]
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::leftRefFunction()
|
|
||||||
{
|
|
||||||
//! [leftRef]
|
|
||||||
QString x = "Pineapple";
|
|
||||||
QStringRef y = x.leftRef(4); // y == "Pine"
|
|
||||||
//! [leftRef]
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::rightRefFunction()
|
|
||||||
{
|
|
||||||
//! [rightRef]
|
|
||||||
QString x = "Pineapple";
|
|
||||||
QStringRef y = x.rightRef(5); // y == "apple"
|
|
||||||
//! [rightRef]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
|
||||||
QString hello("hello");
|
QString hello("hello");
|
||||||
QStringRef el(&hello, 2, 3);
|
QStringView el = QStringView{ hello }.mid(2, 3);
|
||||||
QLatin1String world("world");
|
QLatin1String world("world");
|
||||||
QString message = hello % el % world % QChar('!');
|
QString message = hello % el % world % QChar('!');
|
||||||
//! [5]
|
//! [5]
|
||||||
|
@ -65,7 +65,6 @@ class Q_CORE_EXPORT QLocale
|
|||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
friend class QString;
|
friend class QString;
|
||||||
friend class QStringRef;
|
|
||||||
friend class QByteArray;
|
friend class QByteArray;
|
||||||
friend class QIntValidator;
|
friend class QIntValidator;
|
||||||
friend class QDoubleValidatorPrivate;
|
friend class QDoubleValidatorPrivate;
|
||||||
|
@ -2191,7 +2191,7 @@ QString QRegularExpressionMatch::captured(QStringView name) const
|
|||||||
there is no capturing group named \a name, returns a null QStringView.
|
there is no capturing group named \a name, returns a null QStringView.
|
||||||
|
|
||||||
\sa captured(), capturedStart(), capturedEnd(), capturedLength(),
|
\sa captured(), capturedStart(), capturedEnd(), capturedLength(),
|
||||||
QStringRef::isNull()
|
QStringView::isNull()
|
||||||
*/
|
*/
|
||||||
QStringView QRegularExpressionMatch::capturedView(QStringView name) const
|
QStringView QRegularExpressionMatch::capturedView(QStringView name) const
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -76,7 +76,6 @@ class QRegularExpression;
|
|||||||
class QRegularExpressionMatch;
|
class QRegularExpressionMatch;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
class QStringRef;
|
|
||||||
|
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
template <bool...B> class BoolList;
|
template <bool...B> class BoolList;
|
||||||
@ -449,10 +448,6 @@ public:
|
|||||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return first(size() - n); }
|
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return first(size() - n); }
|
||||||
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QStringRef leftRef(int n) const;
|
|
||||||
Q_REQUIRED_RESULT QStringRef rightRef(int n) const;
|
|
||||||
Q_REQUIRED_RESULT QStringRef midRef(int position, int n = -1) const;
|
|
||||||
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
#if QT_STRINGVIEW_LEVEL < 2
|
||||||
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||||
#endif
|
#endif
|
||||||
@ -570,20 +565,12 @@ public:
|
|||||||
QStringList split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
QStringList split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||||
Q_REQUIRED_RESULT
|
Q_REQUIRED_RESULT
|
||||||
QList<QStringRef> splitRef(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
Q_REQUIRED_RESULT
|
|
||||||
QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||||
Q_REQUIRED_RESULT
|
|
||||||
QList<QStringRef> splitRef(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#ifndef QT_NO_REGULAREXPRESSION
|
#ifndef QT_NO_REGULAREXPRESSION
|
||||||
Q_REQUIRED_RESULT
|
Q_REQUIRED_RESULT
|
||||||
QStringList split(const QRegularExpression &sep,
|
QStringList split(const QRegularExpression &sep,
|
||||||
Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
|
Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
|
||||||
Q_REQUIRED_RESULT
|
|
||||||
QList<QStringRef> splitRef(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Needle, typename...Flags>
|
template <typename Needle, typename...Flags>
|
||||||
@ -820,13 +807,6 @@ public:
|
|||||||
friend inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2);
|
friend inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2);
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2);
|
friend inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2);
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2);
|
friend inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2);
|
||||||
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2);
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QStringRef &s2);
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QStringRef &s2);
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QStringRef &s2);
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2);
|
|
||||||
friend inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef QChar *iterator;
|
typedef QChar *iterator;
|
||||||
@ -910,9 +890,6 @@ private:
|
|||||||
friend inline bool operator==(QChar, const QString &) noexcept;
|
friend inline bool operator==(QChar, const QString &) noexcept;
|
||||||
friend inline bool operator< (QChar, const QString &) noexcept;
|
friend inline bool operator< (QChar, const QString &) noexcept;
|
||||||
friend inline bool operator> (QChar, const QString &) noexcept;
|
friend inline bool operator> (QChar, const QString &) noexcept;
|
||||||
friend inline bool operator==(QChar, const QStringRef &) noexcept;
|
|
||||||
friend inline bool operator< (QChar, const QStringRef &) noexcept;
|
|
||||||
friend inline bool operator> (QChar, const QStringRef &) noexcept;
|
|
||||||
friend inline bool operator==(QChar, QLatin1String) noexcept;
|
friend inline bool operator==(QChar, QLatin1String) noexcept;
|
||||||
friend inline bool operator< (QChar, QLatin1String) noexcept;
|
friend inline bool operator< (QChar, QLatin1String) noexcept;
|
||||||
friend inline bool operator> (QChar, QLatin1String) noexcept;
|
friend inline bool operator> (QChar, QLatin1String) noexcept;
|
||||||
@ -950,7 +927,6 @@ private:
|
|||||||
static qlonglong toIntegral_helper(QStringView string, bool *ok, int base);
|
static qlonglong toIntegral_helper(QStringView string, bool *ok, int base);
|
||||||
static qulonglong toIntegral_helper(QStringView string, bool *ok, uint base);
|
static qulonglong toIntegral_helper(QStringView string, bool *ok, uint base);
|
||||||
void replace_helper(size_t *indices, qsizetype nIndices, qsizetype blen, const QChar *after, qsizetype alen);
|
void replace_helper(size_t *indices, qsizetype nIndices, qsizetype blen, const QChar *after, qsizetype alen);
|
||||||
friend class QStringRef;
|
|
||||||
friend class QStringView;
|
friend class QStringView;
|
||||||
friend class QByteArray;
|
friend class QByteArray;
|
||||||
friend class QCollator;
|
friend class QCollator;
|
||||||
@ -1340,251 +1316,8 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
|
|||||||
Q_DECLARE_SHARED(QString)
|
Q_DECLARE_SHARED(QString)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)
|
||||||
|
|
||||||
|
|
||||||
class Q_CORE_EXPORT QStringRef {
|
|
||||||
const QString *m_string;
|
|
||||||
int m_position;
|
|
||||||
int m_size;
|
|
||||||
public:
|
|
||||||
typedef QString::size_type size_type;
|
|
||||||
typedef QString::value_type value_type;
|
|
||||||
typedef const QChar *const_iterator;
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
||||||
typedef QString::const_pointer const_pointer;
|
|
||||||
typedef QString::const_reference const_reference;
|
|
||||||
|
|
||||||
// ### Qt 6: make this constructor constexpr, after the destructor is made trivial
|
|
||||||
inline QStringRef() : m_string(nullptr), m_position(0), m_size(0) {}
|
|
||||||
inline QStringRef(const QString *string, int position, int size);
|
|
||||||
inline QStringRef(const QString *string);
|
|
||||||
|
|
||||||
inline const QString *string() const { return m_string; }
|
|
||||||
inline int position() const { return m_position; }
|
|
||||||
inline int size() const { return m_size; }
|
|
||||||
inline int count() const { return m_size; }
|
|
||||||
inline int length() const { return m_size; }
|
|
||||||
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#endif
|
|
||||||
Q_REQUIRED_RESULT int indexOf(QStringView s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
|
||||||
{ return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsizetype
|
|
||||||
int indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
int lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#endif
|
|
||||||
int lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
Q_REQUIRED_RESULT int lastIndexOf(QStringView s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
|
||||||
{ return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsizetype
|
|
||||||
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
inline bool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#endif
|
|
||||||
inline bool contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
|
||||||
|
|
||||||
int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT
|
|
||||||
QList<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
Q_REQUIRED_RESULT
|
|
||||||
QList<QStringRef> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
|
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QStringRef left(int n) const;
|
|
||||||
Q_REQUIRED_RESULT QStringRef right(int n) const;
|
|
||||||
Q_REQUIRED_RESULT QStringRef mid(int pos, int n = -1) const;
|
|
||||||
Q_REQUIRED_RESULT QStringRef chopped(int n) const
|
|
||||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return left(size() - n); }
|
|
||||||
|
|
||||||
void truncate(int pos) noexcept { m_size = qBound(0, pos, m_size); }
|
|
||||||
void chop(int n) noexcept
|
|
||||||
{
|
|
||||||
if (n >= m_size)
|
|
||||||
m_size = 0;
|
|
||||||
else if (n > 0)
|
|
||||||
m_size -= n;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isRightToLeft() const;
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
|
||||||
{ return QtPrivate::startsWith(*this, s, cs); }
|
|
||||||
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
bool startsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
|
||||||
{ return QtPrivate::endsWith(*this, s, cs); }
|
|
||||||
bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
bool endsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline QStringRef &operator=(const QString *string);
|
|
||||||
|
|
||||||
inline const QChar *unicode() const
|
|
||||||
{
|
|
||||||
if (!m_string)
|
|
||||||
return reinterpret_cast<const QChar *>(&QString::_empty);
|
|
||||||
return m_string->unicode() + m_position;
|
|
||||||
}
|
|
||||||
inline const QChar *data() const { return unicode(); }
|
|
||||||
inline const QChar *constData() const { return unicode(); }
|
|
||||||
|
|
||||||
inline const_iterator begin() const { return unicode(); }
|
|
||||||
inline const_iterator cbegin() const { return unicode(); }
|
|
||||||
inline const_iterator constBegin() const { return unicode(); }
|
|
||||||
inline const_iterator end() const { return unicode() + size(); }
|
|
||||||
inline const_iterator cend() const { return unicode() + size(); }
|
|
||||||
inline const_iterator constEnd() const { return unicode() + size(); }
|
|
||||||
inline const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
|
||||||
inline const_reverse_iterator crbegin() const { return rbegin(); }
|
|
||||||
inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
|
||||||
inline const_reverse_iterator crend() const { return rend(); }
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QByteArray toLatin1() const;
|
|
||||||
Q_REQUIRED_RESULT QByteArray toUtf8() const;
|
|
||||||
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const;
|
|
||||||
Q_REQUIRED_RESULT QList<uint> toUcs4() const;
|
|
||||||
|
|
||||||
inline void clear() { m_string = nullptr; m_position = m_size = 0; }
|
|
||||||
QString toString() const;
|
|
||||||
inline bool isEmpty() const { return m_size == 0; }
|
|
||||||
inline bool isNull() const { return m_string == nullptr || m_string->isNull(); }
|
|
||||||
|
|
||||||
QStringRef appendTo(QString *string) const;
|
|
||||||
|
|
||||||
inline const QChar at(int i) const
|
|
||||||
{ Q_ASSERT(uint(i) < uint(size())); return m_string->at(i + m_position); }
|
|
||||||
QChar operator[](int i) const { return at(i); }
|
|
||||||
Q_REQUIRED_RESULT QChar front() const { return at(0); }
|
|
||||||
Q_REQUIRED_RESULT QChar back() const { return at(size() - 1); }
|
|
||||||
|
|
||||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
|
||||||
// ASCII compatibility
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator==(const char *s) const;
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const;
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<(const char *s) const;
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<=(const char *s) const;
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>(const char *s) const;
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
|
||||||
int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
|
||||||
int compare(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
|
||||||
{ return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
|
|
||||||
int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
|
||||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
|
||||||
int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
|
|
||||||
{ return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); }
|
|
||||||
#endif
|
|
||||||
static int compare(const QStringRef &s1, const QString &s2,
|
|
||||||
Qt::CaseSensitivity = Qt::CaseSensitive) noexcept;
|
|
||||||
static int compare(const QStringRef &s1, const QStringRef &s2,
|
|
||||||
Qt::CaseSensitivity = Qt::CaseSensitive) noexcept;
|
|
||||||
static int compare(const QStringRef &s1, QLatin1String s2,
|
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
|
|
||||||
|
|
||||||
int localeAwareCompare(const QString &s) const;
|
|
||||||
int localeAwareCompare(const QStringRef &s) const;
|
|
||||||
static int localeAwareCompare(const QStringRef &s1, const QString &s2);
|
|
||||||
static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2);
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QStringRef trimmed() const;
|
|
||||||
short toShort(bool *ok = nullptr, int base = 10) const;
|
|
||||||
ushort toUShort(bool *ok = nullptr, int base = 10) const;
|
|
||||||
int toInt(bool *ok = nullptr, int base = 10) const;
|
|
||||||
uint toUInt(bool *ok = nullptr, int base = 10) const;
|
|
||||||
long toLong(bool *ok = nullptr, int base = 10) const;
|
|
||||||
ulong toULong(bool *ok = nullptr, int base = 10) const;
|
|
||||||
qlonglong toLongLong(bool *ok = nullptr, int base = 10) const;
|
|
||||||
qulonglong toULongLong(bool *ok = nullptr, int base = 10) const;
|
|
||||||
float toFloat(bool *ok = nullptr) const;
|
|
||||||
double toDouble(bool *ok = nullptr) const;
|
|
||||||
};
|
|
||||||
Q_DECLARE_TYPEINFO(QStringRef, Q_PRIMITIVE_TYPE);
|
|
||||||
|
|
||||||
inline QStringRef &QStringRef::operator=(const QString *aString)
|
|
||||||
{ m_string = aString; m_position = 0; m_size = aString?aString->size():0; return *this; }
|
|
||||||
|
|
||||||
inline QStringRef::QStringRef(const QString *aString, int aPosition, int aSize)
|
|
||||||
:m_string(aString), m_position(aPosition), m_size(aSize){}
|
|
||||||
|
|
||||||
inline QStringRef::QStringRef(const QString *aString)
|
|
||||||
:m_string(aString), m_position(0), m_size(aString?aString->size() : 0){}
|
|
||||||
|
|
||||||
// QStringRef <> QStringRef
|
|
||||||
Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) noexcept;
|
|
||||||
inline bool operator!=(const QStringRef &s1, const QStringRef &s2) noexcept
|
|
||||||
{ return !(s1 == s2); }
|
|
||||||
Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) noexcept;
|
|
||||||
inline bool operator>(const QStringRef &s1, const QStringRef &s2) noexcept
|
|
||||||
{ return s2 < s1; }
|
|
||||||
inline bool operator<=(const QStringRef &s1, const QStringRef &s2) noexcept
|
|
||||||
{ return !(s1 > s2); }
|
|
||||||
inline bool operator>=(const QStringRef &s1, const QStringRef &s2) noexcept
|
|
||||||
{ return !(s1 < s2); }
|
|
||||||
|
|
||||||
// QString <> QStringRef
|
|
||||||
Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) noexcept;
|
|
||||||
inline bool operator!=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) != 0; }
|
|
||||||
inline bool operator< (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) < 0; }
|
|
||||||
inline bool operator> (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) > 0; }
|
|
||||||
inline bool operator<=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) <= 0; }
|
|
||||||
inline bool operator>=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) >= 0; }
|
|
||||||
|
|
||||||
inline bool operator==(const QStringRef &lhs, const QString &rhs) noexcept { return rhs == lhs; }
|
|
||||||
inline bool operator!=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs != lhs; }
|
|
||||||
inline bool operator< (const QStringRef &lhs, const QString &rhs) noexcept { return rhs > lhs; }
|
|
||||||
inline bool operator> (const QStringRef &lhs, const QString &rhs) noexcept { return rhs < lhs; }
|
|
||||||
inline bool operator<=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs >= lhs; }
|
|
||||||
inline bool operator>=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs <= lhs; }
|
|
||||||
|
|
||||||
inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcept
|
inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcept
|
||||||
{ return -s.compare(*this, cs); }
|
{ return -s.compare(*this, cs); }
|
||||||
inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const noexcept
|
|
||||||
{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
|
|
||||||
inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const noexcept
|
|
||||||
{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
|
|
||||||
inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
|
|
||||||
{ return QString::compare_helper(constData(), length(), s, cs); }
|
|
||||||
inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) noexcept
|
|
||||||
{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
|
|
||||||
inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) noexcept
|
|
||||||
{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
|
|
||||||
inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) noexcept
|
|
||||||
{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
|
|
||||||
|
|
||||||
// QLatin1String <> QStringRef
|
|
||||||
Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) noexcept;
|
|
||||||
inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) != 0; }
|
|
||||||
inline bool operator< (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) > 0; }
|
|
||||||
inline bool operator> (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) < 0; }
|
|
||||||
inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) >= 0; }
|
|
||||||
inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) <= 0; }
|
|
||||||
|
|
||||||
inline bool operator==(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs == lhs; }
|
|
||||||
inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs != lhs; }
|
|
||||||
inline bool operator< (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs > lhs; }
|
|
||||||
inline bool operator> (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs < lhs; }
|
|
||||||
inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs >= lhs; }
|
|
||||||
inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs <= lhs; }
|
|
||||||
|
|
||||||
// QChar <> QString
|
// QChar <> QString
|
||||||
inline bool operator==(QChar lhs, const QString &rhs) noexcept
|
inline bool operator==(QChar lhs, const QString &rhs) noexcept
|
||||||
@ -1605,25 +1338,6 @@ inline bool operator> (const QString &lhs, QChar rhs) noexcept { return rhs <
|
|||||||
inline bool operator<=(const QString &lhs, QChar rhs) noexcept { return !(rhs < lhs); }
|
inline bool operator<=(const QString &lhs, QChar rhs) noexcept { return !(rhs < lhs); }
|
||||||
inline bool operator>=(const QString &lhs, QChar rhs) noexcept { return !(rhs > lhs); }
|
inline bool operator>=(const QString &lhs, QChar rhs) noexcept { return !(rhs > lhs); }
|
||||||
|
|
||||||
// QChar <> QStringRef
|
|
||||||
inline bool operator==(QChar lhs, const QStringRef &rhs) noexcept
|
|
||||||
{ return rhs.size() == 1 && lhs == rhs.front(); }
|
|
||||||
inline bool operator< (QChar lhs, const QStringRef &rhs) noexcept
|
|
||||||
{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
|
|
||||||
inline bool operator> (QChar lhs, const QStringRef &rhs) noexcept
|
|
||||||
{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
|
|
||||||
|
|
||||||
inline bool operator!=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs == rhs); }
|
|
||||||
inline bool operator<=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs > rhs); }
|
|
||||||
inline bool operator>=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs < rhs); }
|
|
||||||
|
|
||||||
inline bool operator==(const QStringRef &lhs, QChar rhs) noexcept { return rhs == lhs; }
|
|
||||||
inline bool operator!=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs == lhs); }
|
|
||||||
inline bool operator< (const QStringRef &lhs, QChar rhs) noexcept { return rhs > lhs; }
|
|
||||||
inline bool operator> (const QStringRef &lhs, QChar rhs) noexcept { return rhs < lhs; }
|
|
||||||
inline bool operator<=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs < lhs); }
|
|
||||||
inline bool operator>=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs > lhs); }
|
|
||||||
|
|
||||||
// QChar <> QLatin1String
|
// QChar <> QLatin1String
|
||||||
inline bool operator==(QChar lhs, QLatin1String rhs) noexcept
|
inline bool operator==(QChar lhs, QLatin1String rhs) noexcept
|
||||||
{ return rhs.size() == 1 && lhs == rhs.front(); }
|
{ return rhs.size() == 1 && lhs == rhs.front(); }
|
||||||
@ -1681,92 +1395,10 @@ inline bool operator<=(QLatin1String lhs, QStringView rhs) noexcept { return QtP
|
|||||||
inline bool operator> (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
|
inline bool operator> (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
|
||||||
inline bool operator>=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
|
inline bool operator>=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
|
||||||
|
|
||||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
|
||||||
// QStringRef <> QByteArray
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) == 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) != 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator< (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) < 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator> (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) > 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) <= 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) >= 0; }
|
|
||||||
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) == 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) != 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator< (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) > 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator> (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) < 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) >= 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) <= 0; }
|
|
||||||
|
|
||||||
// QStringRef <> const char *
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator==(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) == 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) != 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator<(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) < 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator<=(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) <= 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator>(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) > 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool QStringRef::operator>=(const char *s) const
|
|
||||||
{ return QString::compare_helper(constData(), size(), s, -1) >= 0; }
|
|
||||||
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) == 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; }
|
|
||||||
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2)
|
|
||||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
|
|
||||||
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
|
||||||
|
|
||||||
inline int QString::localeAwareCompare(QStringView s) const
|
inline int QString::localeAwareCompare(QStringView s) const
|
||||||
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
|
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
|
||||||
inline int QString::localeAwareCompare(QStringView s1, QStringView s2)
|
inline int QString::localeAwareCompare(QStringView s1, QStringView s2)
|
||||||
{ return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
|
{ return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
|
||||||
inline int QStringRef::localeAwareCompare(const QString &s) const
|
|
||||||
{ return QString::localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
|
|
||||||
inline int QStringRef::localeAwareCompare(const QStringRef &s) const
|
|
||||||
{ return QString::localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
|
|
||||||
inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QString &s2)
|
|
||||||
{ return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
|
|
||||||
inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef &s2)
|
|
||||||
{ return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
|
|
||||||
|
|
||||||
#if QT_STRINGVIEW_LEVEL < 2
|
|
||||||
inline bool QStringRef::contains(const QString &s, Qt::CaseSensitivity cs) const
|
|
||||||
{ return indexOf(s, 0, cs) != -1; }
|
|
||||||
inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
|
|
||||||
{ return indexOf(s, 0, cs) != -1; }
|
|
||||||
#endif
|
|
||||||
inline bool QStringRef::contains(QLatin1String s, Qt::CaseSensitivity cs) const
|
|
||||||
{ return indexOf(s, 0, cs) != -1; }
|
|
||||||
inline bool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
|
|
||||||
{ return indexOf(c, 0, cs) != -1; }
|
|
||||||
inline bool QStringRef::contains(QStringView s, Qt::CaseSensitivity cs) const noexcept
|
|
||||||
{ return indexOf(s, 0, cs) != -1; }
|
|
||||||
|
|
||||||
#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
|
|
||||||
inline QString operator+(const QString &s1, const QStringRef &s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(const QStringRef &s1, const QString &s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(const QStringRef &s1, QLatin1String s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(QLatin1String s1, const QStringRef &s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(const QStringRef &s1, const QStringRef &s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(const QStringRef &s1, QChar s2)
|
|
||||||
{ QString t; t.reserve(s1.size() + 1); t += s1; t += s2; return t; }
|
|
||||||
inline QString operator+(QChar s1, const QStringRef &s2)
|
|
||||||
{ QString t; t.reserve(1 + s2.size()); t += s1; t += s2; return t; }
|
|
||||||
#endif // !(QT_USE_FAST_OPERATOR_PLUS || QT_USE_QSTRINGBUILDER)
|
|
||||||
|
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
// used by qPrintable() and qUtf8Printable() macros
|
// used by qPrintable() and qUtf8Printable() macros
|
||||||
|
@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
For building QStrings:
|
For building QStrings:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li QString, QStringRef, (since 5.10:) QStringView
|
\li QString, (since 5.10:) QStringView
|
||||||
\li QChar, QLatin1Char, (since 5.10:) \c char16_t,
|
\li QChar, QLatin1Char, (since 5.10:) \c char16_t,
|
||||||
\li QLatin1String,
|
\li QLatin1String,
|
||||||
\li (since 5.10:) \c{const char16_t[]} (\c{u"foo"}),
|
\li (since 5.10:) \c{const char16_t[]} (\c{u"foo"}),
|
||||||
@ -107,7 +107,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
takes a QString parameter.
|
takes a QString parameter.
|
||||||
|
|
||||||
This function is usable with arguments of type \c QString,
|
This function is usable with arguments of type \c QString,
|
||||||
\c QLatin1String, \c QStringRef,
|
\c QLatin1String,
|
||||||
\c QChar, \c QLatin1Char, and \c char.
|
\c QChar, \c QLatin1Char, and \c char.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -266,21 +266,6 @@ template <> struct QConcatenable<QString> : private QAbstractConcatenable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct QConcatenable<QStringRef> : private QAbstractConcatenable
|
|
||||||
{
|
|
||||||
typedef QStringRef type;
|
|
||||||
typedef QString ConvertTo;
|
|
||||||
enum { ExactSize = true };
|
|
||||||
static int size(const QStringRef &a) { return a.size(); }
|
|
||||||
static inline void appendTo(const QStringRef &a, QChar *&out)
|
|
||||||
{
|
|
||||||
const int n = a.size();
|
|
||||||
if (n)
|
|
||||||
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n);
|
|
||||||
out += n;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <> struct QConcatenable<QStringView> : private QAbstractConcatenable
|
template <> struct QConcatenable<QStringView> : private QAbstractConcatenable
|
||||||
{
|
{
|
||||||
typedef QStringView type;
|
typedef QStringView type;
|
||||||
|
@ -326,11 +326,11 @@ enum DataEndianness
|
|||||||
|
|
||||||
struct QUtf8
|
struct QUtf8
|
||||||
{
|
{
|
||||||
static QChar *convertToUnicode(QChar *, const char *, qsizetype) noexcept;
|
Q_CORE_EXPORT static QChar *convertToUnicode(QChar *, const char *, qsizetype) noexcept;
|
||||||
static QString convertToUnicode(const char *, qsizetype);
|
static QString convertToUnicode(const char *, qsizetype);
|
||||||
Q_CORE_EXPORT static QString convertToUnicode(const char *, qsizetype, QStringConverter::State *);
|
Q_CORE_EXPORT static QString convertToUnicode(const char *, qsizetype, QStringConverter::State *);
|
||||||
static QChar *convertToUnicode(QChar *out, const char *in, qsizetype length, QStringConverter::State *state);
|
static QChar *convertToUnicode(QChar *out, const char *in, qsizetype length, QStringConverter::State *state);
|
||||||
static QByteArray convertFromUnicode(const QChar *, qsizetype);
|
Q_CORE_EXPORT static QByteArray convertFromUnicode(const QChar *, qsizetype);
|
||||||
Q_CORE_EXPORT static QByteArray convertFromUnicode(const QChar *, qsizetype, QStringConverter::State *);
|
Q_CORE_EXPORT static QByteArray convertFromUnicode(const QChar *, qsizetype, QStringConverter::State *);
|
||||||
static char *convertFromUnicode(char *out, QStringView in, QStringConverter::State *state);
|
static char *convertFromUnicode(char *out, QStringView in, QStringConverter::State *state);
|
||||||
struct ValidUtf8Result {
|
struct ValidUtf8Result {
|
||||||
|
@ -173,7 +173,6 @@ namespace Tok {
|
|||||||
template <> struct ViewForImpl<QLatin1String> { using type = QLatin1String; };
|
template <> struct ViewForImpl<QLatin1String> { using type = QLatin1String; };
|
||||||
template <> struct ViewForImpl<QChar> { using type = QChar; };
|
template <> struct ViewForImpl<QChar> { using type = QChar; };
|
||||||
template <> struct ViewForImpl<QString> : ViewForImpl<QStringView> {};
|
template <> struct ViewForImpl<QString> : ViewForImpl<QStringView> {};
|
||||||
template <> struct ViewForImpl<QStringRef> : ViewForImpl<QStringView> {};
|
|
||||||
template <> struct ViewForImpl<QLatin1Char> : ViewForImpl<QChar> {};
|
template <> struct ViewForImpl<QLatin1Char> : ViewForImpl<QChar> {};
|
||||||
template <> struct ViewForImpl<char16_t> : ViewForImpl<QChar> {};
|
template <> struct ViewForImpl<char16_t> : ViewForImpl<QChar> {};
|
||||||
template <> struct ViewForImpl<char16_t*> : ViewForImpl<QStringView> {};
|
template <> struct ViewForImpl<char16_t*> : ViewForImpl<QStringView> {};
|
||||||
|
@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
When used as an interface type, QStringView allows a single function to accept
|
When used as an interface type, QStringView allows a single function to accept
|
||||||
a wide variety of UTF-16 string data sources. One function accepting QStringView
|
a wide variety of UTF-16 string data sources. One function accepting QStringView
|
||||||
thus replaces three function overloads (taking QString, QStringRef, and
|
thus replaces three function overloads (taking QString and
|
||||||
\c{(const QChar*, int)}), while at the same time enabling even more string data
|
\c{(const QChar*, int)}), while at the same time enabling even more string data
|
||||||
sources to be passed to the function, such as \c{u"Hello World"}, a \c char16_t
|
sources to be passed to the function, such as \c{u"Hello World"}, a \c char16_t
|
||||||
string literal.
|
string literal.
|
||||||
@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
allowed in \c constexpr functions). You can use an indexed loop and/or utf16() in
|
allowed in \c constexpr functions). You can use an indexed loop and/or utf16() in
|
||||||
\c constexpr contexts instead.
|
\c constexpr contexts instead.
|
||||||
|
|
||||||
\sa QString, QStringRef
|
\sa QString
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -304,16 +304,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
The string view will be null if and only if \c{str.isNull()}.
|
The string view will be null if and only if \c{str.isNull()}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QStringView::QStringView(const QStringRef &str)
|
|
||||||
|
|
||||||
Constructs a string view on \a str.
|
|
||||||
|
|
||||||
\c{str.data()} must remain valid for the lifetime of this string view object.
|
|
||||||
|
|
||||||
The string view will be null if and only if \c{str.isNull()}.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename StdBasicString> QStringView::QStringView(const StdBasicString &str)
|
\fn template <typename StdBasicString> QStringView::QStringView(const StdBasicString &str)
|
||||||
|
|
||||||
@ -496,7 +486,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
Returns the size of this string view, in UTF-16 code points (that is,
|
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
|
surrogate pairs count as two for the purposes of this function, the same
|
||||||
as in QString and QStringRef).
|
as in QString).
|
||||||
|
|
||||||
\sa empty(), isEmpty(), isNull(), length()
|
\sa empty(), isEmpty(), isNull(), length()
|
||||||
*/
|
*/
|
||||||
@ -918,10 +908,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
Returns a string-view that references \a{s}' data, but is never null.
|
Returns a string-view that references \a{s}' data, but is never null.
|
||||||
|
|
||||||
This is a faster way to convert a QString or QStringRef to a QStringView,
|
This is a faster way to convert a QString to a QStringView,
|
||||||
if null QStrings can legitimately be treated as empty ones.
|
if null QStrings can legitimately be treated as empty ones.
|
||||||
|
|
||||||
\sa QString::isNull(), QStringRef::isNull(), QStringView
|
\sa QString::isNull(), QStringView
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -46,9 +46,7 @@
|
|||||||
1. offer QStringView, overload some functions taking QString with
|
1. offer QStringView, overload some functions taking QString with
|
||||||
QStringView
|
QStringView
|
||||||
|
|
||||||
2. like 1, but remove all overloads of functions taking QStringRef,
|
2. Obsolete: QStringRef and its overloads have been removed.
|
||||||
leaving only the function taking QStringView. Do this only where
|
|
||||||
QStringRef overloads tradionally existed.
|
|
||||||
|
|
||||||
3. like 2, but replace functions taking QString, too.
|
3. like 2, but replace functions taking QString, too.
|
||||||
*/
|
*/
|
||||||
@ -71,7 +69,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
class QStringRef;
|
|
||||||
class QStringView;
|
class QStringView;
|
||||||
class QRegularExpression;
|
class QRegularExpression;
|
||||||
|
|
||||||
@ -113,7 +110,6 @@ struct IsContainerCompatibleWithQStringView<T, std::enable_if_t<std::conjunction
|
|||||||
|
|
||||||
// These need to be treated specially due to the empty vs null distinction
|
// These need to be treated specially due to the empty vs null distinction
|
||||||
std::negation<std::is_same<std::decay_t<T>, QString>>,
|
std::negation<std::is_same<std::decay_t<T>, QString>>,
|
||||||
std::negation<std::is_same<std::decay_t<T>, QStringRef>>,
|
|
||||||
|
|
||||||
// Don't make an accidental copy constructor
|
// Don't make an accidental copy constructor
|
||||||
std::negation<std::is_same<std::decay_t<T>, QStringView>>
|
std::negation<std::is_same<std::decay_t<T>, QStringView>>
|
||||||
@ -146,7 +142,7 @@ private:
|
|||||||
using if_compatible_pointer = typename std::enable_if<QtPrivate::IsCompatiblePointer<Pointer>::value, bool>::type;
|
using if_compatible_pointer = typename std::enable_if<QtPrivate::IsCompatiblePointer<Pointer>::value, bool>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type;
|
using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value, bool>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using if_compatible_container = typename std::enable_if<QtPrivate::IsContainerCompatibleWithQStringView<T>::value, bool>::type;
|
using if_compatible_container = typename std::enable_if<QtPrivate::IsContainerCompatibleWithQStringView<T>::value, bool>::type;
|
||||||
@ -217,7 +213,6 @@ public:
|
|||||||
|
|
||||||
#ifdef Q_CLANG_QDOC
|
#ifdef Q_CLANG_QDOC
|
||||||
QStringView(const QString &str) noexcept;
|
QStringView(const QString &str) noexcept;
|
||||||
QStringView(const QStringRef &str) noexcept;
|
|
||||||
#else
|
#else
|
||||||
template <typename String, if_compatible_qstring_like<String> = true>
|
template <typename String, if_compatible_qstring_like<String> = true>
|
||||||
QStringView(const String &str) noexcept
|
QStringView(const String &str) noexcept
|
||||||
@ -415,7 +410,7 @@ private:
|
|||||||
Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE);
|
Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
template <typename QStringLike, typename std::enable_if<
|
template <typename QStringLike, typename std::enable_if<
|
||||||
std::is_same<QStringLike, QString>::value || std::is_same<QStringLike, QStringRef>::value,
|
std::is_same<QStringLike, QString>::value,
|
||||||
bool>::type = true>
|
bool>::type = true>
|
||||||
inline QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
|
inline QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
|
||||||
{ return QStringView(s.data(), s.size()); }
|
{ return QStringView(s.data(), s.size()); }
|
||||||
|
@ -1200,7 +1200,7 @@ private:
|
|||||||
path = QFile::symLinkTarget(path);
|
path = QFile::symLinkTarget(path);
|
||||||
int index = path.indexOf(zoneinfo);
|
int index = path.indexOf(zoneinfo);
|
||||||
if (index >= 0) // Found zoneinfo file; extract zone name from path:
|
if (index >= 0) // Found zoneinfo file; extract zone name from path:
|
||||||
return path.midRef(index + zoneinfo.size()).toUtf8();
|
return QStringView{ path }.mid(index + zoneinfo.size()).toUtf8();
|
||||||
} while (!path.isEmpty() && --iteration > 0);
|
} while (!path.isEmpty() && --iteration > 0);
|
||||||
|
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
@ -1049,13 +1049,6 @@ size_t qHash(long double key, size_t seed) noexcept
|
|||||||
Returns the hash value for the \a key, using \a seed to seed the calculation.
|
Returns the hash value for the \a key, using \a seed to seed the calculation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \fn size_t qHash(const QStringRef &key, size_t seed = 0)
|
|
||||||
\relates QHash
|
|
||||||
\since 5.0
|
|
||||||
|
|
||||||
Returns the hash value for the \a key, using \a seed to seed the calculation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \fn size_t qHash(QStringView key, size_t seed = 0)
|
/*! \fn size_t qHash(QStringView key, size_t seed = 0)
|
||||||
\relates QStringView
|
\relates QStringView
|
||||||
\since 5.10
|
\since 5.10
|
||||||
|
@ -62,7 +62,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QBitArray;
|
class QBitArray;
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringRef;
|
|
||||||
class QLatin1String;
|
class QLatin1String;
|
||||||
|
|
||||||
Q_CORE_EXPORT int qGlobalQHashSeed();
|
Q_CORE_EXPORT int qGlobalQHashSeed();
|
||||||
@ -160,8 +159,6 @@ Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QStringView key, size_t seed = 0
|
|||||||
#if QT_STRINGVIEW_LEVEL < 2
|
#if QT_STRINGVIEW_LEVEL < 2
|
||||||
inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept
|
inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept
|
||||||
{ return qHash(QStringView{key}, seed); }
|
{ return qHash(QStringView{key}, seed); }
|
||||||
inline Q_DECL_PURE_FUNCTION size_t qHash(const QStringRef &key, size_t seed = 0) noexcept
|
|
||||||
{ return qHash(QStringView{key}, seed); }
|
|
||||||
#endif
|
#endif
|
||||||
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept;
|
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept;
|
||||||
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept;
|
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept;
|
||||||
@ -290,7 +287,6 @@ template <typename T1, typename T2> inline size_t qHash(const std::pair<T1, T2>
|
|||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH(Class, argument_type)
|
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH(Class, argument_type)
|
||||||
|
|
||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QString)
|
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QString)
|
||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QStringRef)
|
|
||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QStringView)
|
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QStringView)
|
||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1String)
|
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1String)
|
||||||
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QByteArray)
|
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QByteArray)
|
||||||
|
@ -435,7 +435,7 @@ static QString strippedText(QString s)
|
|||||||
Q_UNUSED(sender);
|
Q_UNUSED(sender);
|
||||||
if (mHelper && [mSavePanel isVisible]) {
|
if (mHelper && [mSavePanel isVisible]) {
|
||||||
QString selection = QString::fromNSString([[mSavePanel URL] path]);
|
QString selection = QString::fromNSString([[mSavePanel URL] path]);
|
||||||
if (selection != mCurrentSelection) {
|
if (selection != *mCurrentSelection) {
|
||||||
*mCurrentSelection = selection;
|
*mCurrentSelection = selection;
|
||||||
mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection);
|
mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,6 @@ QT_CLASS_LIB(QString, QtCore, qstring.h)
|
|||||||
QT_CLASS_LIB(QLatin1String, QtCore, qstring.h)
|
QT_CLASS_LIB(QLatin1String, QtCore, qstring.h)
|
||||||
QT_CLASS_LIB(QCharRef, QtCore, qstring.h)
|
QT_CLASS_LIB(QCharRef, QtCore, qstring.h)
|
||||||
QT_CLASS_LIB(QConstString, QtCore, qstring.h)
|
QT_CLASS_LIB(QConstString, QtCore, qstring.h)
|
||||||
QT_CLASS_LIB(QStringRef, QtCore, qstring.h)
|
|
||||||
QT_CLASS_LIB(QLatin1Literal, QtCore, qstring.h)
|
QT_CLASS_LIB(QLatin1Literal, QtCore, qstring.h)
|
||||||
QT_CLASS_LIB(QAbstractConcatenable, QtCore, qstringbuilder.h)
|
QT_CLASS_LIB(QAbstractConcatenable, QtCore, qstringbuilder.h)
|
||||||
QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
|
QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
|
||||||
|
@ -66,7 +66,6 @@ private slots:
|
|||||||
void veryLongWarningMessage() const;
|
void veryLongWarningMessage() const;
|
||||||
void qDebugQChar() const;
|
void qDebugQChar() const;
|
||||||
void qDebugQString() const;
|
void qDebugQString() const;
|
||||||
void qDebugQStringRef() const;
|
|
||||||
void qDebugQStringView() const;
|
void qDebugQStringView() const;
|
||||||
void qDebugQLatin1String() const;
|
void qDebugQLatin1String() const;
|
||||||
void qDebugQByteArray() const;
|
void qDebugQByteArray() const;
|
||||||
@ -438,7 +437,7 @@ void tst_QDebug::qDebugQString() const
|
|||||||
QString file, function;
|
QString file, function;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
const QString in(QLatin1String("input"));
|
const QString in(QLatin1String("input"));
|
||||||
const QStringRef inRef(&in);
|
const QStringView inRef{ in };
|
||||||
|
|
||||||
MessageHandlerSetter mhs(myMessageHandler);
|
MessageHandlerSetter mhs(myMessageHandler);
|
||||||
{ qDebug() << inRef; }
|
{ qDebug() << inRef; }
|
||||||
@ -509,47 +508,6 @@ void tst_QDebug::qDebugQString() const
|
|||||||
QCOMPARE(s_msg, QString("\"\\uDC00\\uD800x\\uD800\""));
|
QCOMPARE(s_msg, QString("\"\\uDC00\\uD800x\\uD800\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDebug::qDebugQStringRef() const
|
|
||||||
{
|
|
||||||
/* Use a basic string. */
|
|
||||||
{
|
|
||||||
QString file, function;
|
|
||||||
int line = 0;
|
|
||||||
const QString in(QLatin1String("input"));
|
|
||||||
const QStringRef inRef(&in);
|
|
||||||
|
|
||||||
MessageHandlerSetter mhs(myMessageHandler);
|
|
||||||
{ qDebug() << inRef; }
|
|
||||||
#ifndef QT_NO_MESSAGELOGCONTEXT
|
|
||||||
file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO;
|
|
||||||
#endif
|
|
||||||
QCOMPARE(s_msgType, QtDebugMsg);
|
|
||||||
QCOMPARE(s_msg, QString::fromLatin1("\"input\""));
|
|
||||||
QCOMPARE(QString::fromLatin1(s_file), file);
|
|
||||||
QCOMPARE(s_line, line);
|
|
||||||
QCOMPARE(QString::fromLatin1(s_function), function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use a null QStringRef. */
|
|
||||||
{
|
|
||||||
QString file, function;
|
|
||||||
int line = 0;
|
|
||||||
|
|
||||||
const QStringRef inRef;
|
|
||||||
|
|
||||||
MessageHandlerSetter mhs(myMessageHandler);
|
|
||||||
{ qDebug() << inRef; }
|
|
||||||
#ifndef QT_NO_MESSAGELOGCONTEXT
|
|
||||||
file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO;
|
|
||||||
#endif
|
|
||||||
QCOMPARE(s_msgType, QtDebugMsg);
|
|
||||||
QCOMPARE(s_msg, QString::fromLatin1("\"\""));
|
|
||||||
QCOMPARE(QString::fromLatin1(s_file), file);
|
|
||||||
QCOMPARE(s_line, line);
|
|
||||||
QCOMPARE(QString::fromLatin1(s_function), function);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QDebug::qDebugQStringView() const
|
void tst_QDebug::qDebugQStringView() const
|
||||||
{
|
{
|
||||||
/* Use a basic string. */
|
/* Use a basic string. */
|
||||||
|
@ -2528,10 +2528,10 @@ void tst_QTextStream::stringref_write_operator_ToDevice()
|
|||||||
stream.setEncoding(QStringConverter::Latin1);
|
stream.setEncoding(QStringConverter::Latin1);
|
||||||
stream.setAutoDetectUnicode(true);
|
stream.setAutoDetectUnicode(true);
|
||||||
|
|
||||||
const QString expected = "No explicit lengthExplicit length";
|
const QStringView expected = u"No explicit lengthExplicit length";
|
||||||
|
|
||||||
stream << expected.leftRef(18);
|
stream << expected.left(18);
|
||||||
stream << expected.midRef(18);
|
stream << expected.mid(18);
|
||||||
stream.flush();
|
stream.flush();
|
||||||
QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length");
|
QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length");
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,5 @@ add_subdirectory(qstringbuilder)
|
|||||||
add_subdirectory(qstringiterator)
|
add_subdirectory(qstringiterator)
|
||||||
add_subdirectory(qstringlist)
|
add_subdirectory(qstringlist)
|
||||||
add_subdirectory(qstringmatcher)
|
add_subdirectory(qstringmatcher)
|
||||||
add_subdirectory(qstringref)
|
|
||||||
add_subdirectory(qstringview)
|
add_subdirectory(qstringview)
|
||||||
add_subdirectory(qtextboundaryfinder)
|
add_subdirectory(qtextboundaryfinder)
|
||||||
|
@ -19,7 +19,6 @@ add_subdirectory(qstringconverter)
|
|||||||
add_subdirectory(qstringiterator)
|
add_subdirectory(qstringiterator)
|
||||||
add_subdirectory(qstringlist)
|
add_subdirectory(qstringlist)
|
||||||
add_subdirectory(qstringmatcher)
|
add_subdirectory(qstringmatcher)
|
||||||
add_subdirectory(qstringref)
|
|
||||||
add_subdirectory(qstringtokenizer)
|
add_subdirectory(qstringtokenizer)
|
||||||
add_subdirectory(qstringview)
|
add_subdirectory(qstringview)
|
||||||
add_subdirectory(qtextboundaryfinder)
|
add_subdirectory(qtextboundaryfinder)
|
||||||
|
@ -910,7 +910,7 @@ void tst_QLocale::stringToDouble()
|
|||||||
QFETCH(QString, num_str);
|
QFETCH(QString, num_str);
|
||||||
QFETCH(bool, good);
|
QFETCH(bool, good);
|
||||||
QFETCH(double, num);
|
QFETCH(double, num);
|
||||||
QStringRef num_strRef = num_str.leftRef(-1);
|
QStringView num_strRef{ num_str };
|
||||||
|
|
||||||
QLocale locale(locale_name);
|
QLocale locale(locale_name);
|
||||||
QCOMPARE(locale.name(), locale_name);
|
QCOMPARE(locale.name(), locale_name);
|
||||||
@ -996,7 +996,7 @@ void tst_QLocale::stringToFloat()
|
|||||||
QFETCH(QString, num_str);
|
QFETCH(QString, num_str);
|
||||||
QFETCH(bool, good);
|
QFETCH(bool, good);
|
||||||
QFETCH(double, num);
|
QFETCH(double, num);
|
||||||
QStringRef num_strRef = num_str.leftRef(-1);
|
QStringView num_strRef{ num_str };
|
||||||
float fnum = num;
|
float fnum = num;
|
||||||
|
|
||||||
QLocale locale(locale_name);
|
QLocale locale(locale_name);
|
||||||
@ -1289,8 +1289,8 @@ void tst_QLocale::strtod()
|
|||||||
QCOMPARE(actualOk, ok);
|
QCOMPARE(actualOk, ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and QStringRef, but we can limit the length without allocating memory
|
// and QStringView, but we can limit the length without allocating memory
|
||||||
QStringRef num_strref(&num_str, 0, processed);
|
QStringView num_strref = QStringView{ num_str }.mid(0, processed);
|
||||||
actualOk = false;
|
actualOk = false;
|
||||||
QCOMPARE(QLocale::c().toDouble(num_strref, &actualOk), num);
|
QCOMPARE(QLocale::c().toDouble(num_strref, &actualOk), num);
|
||||||
QCOMPARE(actualOk, ok);
|
QCOMPARE(actualOk, ok);
|
||||||
@ -1355,7 +1355,7 @@ void tst_QLocale::long_long_conversion()
|
|||||||
QFETCH(QString, num_str);
|
QFETCH(QString, num_str);
|
||||||
QFETCH(bool, good);
|
QFETCH(bool, good);
|
||||||
QFETCH(qlonglong, num);
|
QFETCH(qlonglong, num);
|
||||||
QStringRef num_strRef = num_str.leftRef(-1);
|
QStringView num_strRef{ num_str };
|
||||||
|
|
||||||
QLocale locale(locale_name);
|
QLocale locale(locale_name);
|
||||||
QCOMPARE(locale.name(), locale_name);
|
QCOMPARE(locale.name(), locale_name);
|
||||||
|
@ -75,7 +75,7 @@ private slots:
|
|||||||
void regularExpressionMatch();
|
void regularExpressionMatch();
|
||||||
void JOptionUsage_data();
|
void JOptionUsage_data();
|
||||||
void JOptionUsage();
|
void JOptionUsage();
|
||||||
void QStringAndQStringRefEquivalence();
|
void QStringAndQStringViewEquivalence();
|
||||||
void threadSafety_data();
|
void threadSafety_data();
|
||||||
void threadSafety();
|
void threadSafety();
|
||||||
|
|
||||||
@ -1706,7 +1706,7 @@ void tst_QRegularExpression::JOptionUsage()
|
|||||||
QCOMPARE(re.isValid(), isValid);
|
QCOMPARE(re.isValid(), isValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
void tst_QRegularExpression::QStringAndQStringViewEquivalence()
|
||||||
{
|
{
|
||||||
const QString subject = QStringLiteral("Mississippi");
|
const QString subject = QStringLiteral("Mississippi");
|
||||||
{
|
{
|
||||||
@ -1722,7 +1722,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QCOMPARE(match.capturedEnd(), 4);
|
QCOMPARE(match.capturedEnd(), 4);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(QStringRef(&subject));
|
const QRegularExpressionMatch match = re.match(QStringView(subject));
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch());
|
QVERIFY(match.hasMatch());
|
||||||
@ -1740,7 +1740,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QCOMPARE(match.capturedEnd(), 4);
|
QCOMPARE(match.capturedEnd(), 4);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(QStringRef(&subject), 1);
|
const QRegularExpressionMatch match = re.match(QStringView(subject), 1);
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch());
|
QVERIFY(match.hasMatch());
|
||||||
@ -1758,7 +1758,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QCOMPARE(match.capturedEnd(), 6);
|
QCOMPARE(match.capturedEnd(), 6);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(subject.midRef(1));
|
const QRegularExpressionMatch match = re.match(QStringView(subject).mid(1));
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch());
|
QVERIFY(match.hasMatch());
|
||||||
@ -1776,7 +1776,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QCOMPARE(match.capturedEnd(), 6);
|
QCOMPARE(match.capturedEnd(), 6);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(subject.midRef(1), 1);
|
const QRegularExpressionMatch match = re.match(QStringView(subject).mid(1), 1);
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch());
|
QVERIFY(match.hasMatch());
|
||||||
@ -1794,7 +1794,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QCOMPARE(match.capturedEnd(), 7);
|
QCOMPARE(match.capturedEnd(), 7);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(QStringRef(&subject), 4);
|
const QRegularExpressionMatch match = re.match(QStringView(subject), 4);
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(match.hasMatch());
|
QVERIFY(match.hasMatch());
|
||||||
@ -1809,7 +1809,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!match.hasMatch());
|
QVERIFY(!match.hasMatch());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QRegularExpressionMatch match = re.match(subject.midRef(4));
|
const QRegularExpressionMatch match = re.match(QStringView(subject).mid(4));
|
||||||
consistencyCheck(match);
|
consistencyCheck(match);
|
||||||
QVERIFY(match.isValid());
|
QVERIFY(match.isValid());
|
||||||
QVERIFY(!match.hasMatch());
|
QVERIFY(!match.hasMatch());
|
||||||
@ -1842,7 +1842,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject));
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject));
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -1894,7 +1894,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject), 1);
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject), 1);
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -1936,7 +1936,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1));
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject).mid(1));
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -1968,7 +1968,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1), 1);
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject).mid(1), 1);
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -2000,7 +2000,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(1), 1);
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject).mid(1), 1);
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -2033,7 +2033,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(QStringRef(&subject), 4);
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject), 4);
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
|
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
@ -2055,7 +2055,7 @@ void tst_QRegularExpression::QStringAndQStringRefEquivalence()
|
|||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(subject.midRef(4));
|
QRegularExpressionMatchIterator i = re.globalMatch(QStringView(subject).mid(4));
|
||||||
consistencyCheck(i);
|
consistencyCheck(i);
|
||||||
QVERIFY(i.isValid());
|
QVERIFY(i.isValid());
|
||||||
QVERIFY(!i.hasNext());
|
QVERIFY(!i.hasNext());
|
||||||
|
@ -53,9 +53,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define CREATE_REF(string) \
|
#define CREATE_VIEW(string) \
|
||||||
const QString padded = QLatin1Char(' ') + string + QLatin1Char(' '); \
|
const QString padded = QLatin1Char(' ') + string + QLatin1Char(' '); \
|
||||||
QStringRef ref = padded.midRef(1, padded.size() - 2);
|
const QStringView view = QStringView{ padded }.mid(1, padded.size() - 2);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -118,23 +118,6 @@ public:
|
|||||||
{ (s.*mf)(a1, this->pinned); }
|
{ (s.*mf)(a1, this->pinned); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
class Arg<QStringRef> : ArgBase
|
|
||||||
{
|
|
||||||
QStringRef ref() const
|
|
||||||
{ return QStringRef(&pinned); }
|
|
||||||
public:
|
|
||||||
explicit Arg(const char *str) : ArgBase(str) {}
|
|
||||||
|
|
||||||
template <typename MemFun>
|
|
||||||
void apply0(QString &s, MemFun mf) const
|
|
||||||
{ (s.*mf)(ref()); }
|
|
||||||
|
|
||||||
template <typename MemFun, typename A1>
|
|
||||||
void apply1(QString &s, MemFun mf, A1 a1) const
|
|
||||||
{ (s.*mf)(a1, ref()); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class Arg<QStringView> : ArgBase
|
class Arg<QStringView> : ArgBase
|
||||||
{
|
{
|
||||||
@ -482,10 +465,6 @@ private slots:
|
|||||||
void mid();
|
void mid();
|
||||||
void right();
|
void right();
|
||||||
void left();
|
void left();
|
||||||
void midRef();
|
|
||||||
void rightRef();
|
|
||||||
void leftRef();
|
|
||||||
void stringRef();
|
|
||||||
void contains();
|
void contains();
|
||||||
void count();
|
void count();
|
||||||
void lastIndexOf_data();
|
void lastIndexOf_data();
|
||||||
@ -530,12 +509,6 @@ private slots:
|
|||||||
void fromLatin1Roundtrip();
|
void fromLatin1Roundtrip();
|
||||||
void toLatin1Roundtrip_data();
|
void toLatin1Roundtrip_data();
|
||||||
void toLatin1Roundtrip();
|
void toLatin1Roundtrip();
|
||||||
void stringRef_toLatin1Roundtrip_data();
|
|
||||||
void stringRef_toLatin1Roundtrip();
|
|
||||||
void stringRef_utf8_data();
|
|
||||||
void stringRef_utf8();
|
|
||||||
void stringRef_local8Bit_data();
|
|
||||||
void stringRef_local8Bit();
|
|
||||||
void fromLatin1();
|
void fromLatin1();
|
||||||
void fromUcs4();
|
void fromUcs4();
|
||||||
void toUcs4();
|
void toUcs4();
|
||||||
@ -561,10 +534,6 @@ private slots:
|
|||||||
void split();
|
void split();
|
||||||
void split_regularexpression_data();
|
void split_regularexpression_data();
|
||||||
void split_regularexpression();
|
void split_regularexpression();
|
||||||
void splitRef_data();
|
|
||||||
void splitRef();
|
|
||||||
void splitRef_regularexpression_data();
|
|
||||||
void splitRef_regularexpression();
|
|
||||||
void fromUtf16_data();
|
void fromUtf16_data();
|
||||||
void fromUtf16();
|
void fromUtf16();
|
||||||
void fromUtf16_char16_data();
|
void fromUtf16_char16_data();
|
||||||
@ -583,7 +552,6 @@ private slots:
|
|||||||
void repeatedSignature() const;
|
void repeatedSignature() const;
|
||||||
void repeated() const;
|
void repeated() const;
|
||||||
void repeated_data() const;
|
void repeated_data() const;
|
||||||
void compareRef();
|
|
||||||
void arg_locale();
|
void arg_locale();
|
||||||
#if QT_CONFIG(icu)
|
#if QT_CONFIG(icu)
|
||||||
void toUpperLower_icu();
|
void toUpperLower_icu();
|
||||||
@ -1451,14 +1419,14 @@ void tst_QString::indexOf()
|
|||||||
QFETCH( int, startpos );
|
QFETCH( int, startpos );
|
||||||
QFETCH( bool, bcs );
|
QFETCH( bool, bcs );
|
||||||
QFETCH( int, resultpos );
|
QFETCH( int, resultpos );
|
||||||
CREATE_REF(needle);
|
CREATE_VIEW(needle);
|
||||||
|
|
||||||
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||||
|
|
||||||
bool needleIsLatin = (QString::fromLatin1(needle.toLatin1()) == needle);
|
bool needleIsLatin = (QString::fromLatin1(needle.toLatin1()) == needle);
|
||||||
|
|
||||||
QCOMPARE( haystack.indexOf(needle, startpos, cs), resultpos );
|
QCOMPARE( haystack.indexOf(needle, startpos, cs), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(ref, startpos, cs), resultpos );
|
QCOMPARE( haystack.indexOf(view, startpos, cs), resultpos );
|
||||||
if (needleIsLatin) {
|
if (needleIsLatin) {
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos, cs), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos, cs), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos, cs), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos, cs), resultpos );
|
||||||
@ -1487,14 +1455,14 @@ void tst_QString::indexOf()
|
|||||||
|
|
||||||
if (cs == Qt::CaseSensitive) {
|
if (cs == Qt::CaseSensitive) {
|
||||||
QCOMPARE( haystack.indexOf(needle, startpos), resultpos );
|
QCOMPARE( haystack.indexOf(needle, startpos), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(ref, startpos), resultpos );
|
QCOMPARE( haystack.indexOf(view, startpos), resultpos );
|
||||||
if (needleIsLatin) {
|
if (needleIsLatin) {
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos), resultpos );
|
||||||
}
|
}
|
||||||
if (startpos == 0) {
|
if (startpos == 0) {
|
||||||
QCOMPARE( haystack.indexOf(needle), resultpos );
|
QCOMPARE( haystack.indexOf(needle), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(ref), resultpos );
|
QCOMPARE( haystack.indexOf(view), resultpos );
|
||||||
if (needleIsLatin) {
|
if (needleIsLatin) {
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1()), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1()), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(needle.toLatin1().data()), resultpos );
|
QCOMPARE( haystack.indexOf(needle.toLatin1().data()), resultpos );
|
||||||
@ -1503,7 +1471,7 @@ void tst_QString::indexOf()
|
|||||||
}
|
}
|
||||||
if (needle.size() == 1) {
|
if (needle.size() == 1) {
|
||||||
QCOMPARE(haystack.indexOf(needle.at(0), startpos, cs), resultpos);
|
QCOMPARE(haystack.indexOf(needle.at(0), startpos, cs), resultpos);
|
||||||
QCOMPARE(haystack.indexOf(ref.at(0), startpos, cs), resultpos);
|
QCOMPARE(haystack.indexOf(view.at(0), startpos, cs), resultpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1564,17 +1532,17 @@ void tst_QString::indexOf2()
|
|||||||
QFETCH( QString, haystack );
|
QFETCH( QString, haystack );
|
||||||
QFETCH( QString, needle );
|
QFETCH( QString, needle );
|
||||||
QFETCH( int, resultpos );
|
QFETCH( int, resultpos );
|
||||||
CREATE_REF(needle);
|
CREATE_VIEW(needle);
|
||||||
|
|
||||||
QByteArray chaystack = haystack.toLatin1();
|
QByteArray chaystack = haystack.toLatin1();
|
||||||
QByteArray cneedle = needle.toLatin1();
|
QByteArray cneedle = needle.toLatin1();
|
||||||
int got;
|
int got;
|
||||||
|
|
||||||
QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseSensitive), resultpos );
|
QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseSensitive), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseSensitive), resultpos );
|
QCOMPARE( haystack.indexOf(view, 0, Qt::CaseSensitive), resultpos );
|
||||||
QCOMPARE( QStringMatcher(needle, Qt::CaseSensitive).indexIn(haystack, 0), resultpos );
|
QCOMPARE( QStringMatcher(needle, Qt::CaseSensitive).indexIn(haystack, 0), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseInsensitive), resultpos );
|
QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseInsensitive), resultpos );
|
||||||
QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseInsensitive), resultpos );
|
QCOMPARE( haystack.indexOf(view, 0, Qt::CaseInsensitive), resultpos );
|
||||||
QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos );
|
QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos );
|
||||||
if ( needle.length() > 0 ) {
|
if ( needle.length() > 0 ) {
|
||||||
got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive );
|
got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive );
|
||||||
@ -1655,12 +1623,12 @@ void tst_QString::lastIndexOf()
|
|||||||
QFETCH(int, from);
|
QFETCH(int, from);
|
||||||
QFETCH(int, expected);
|
QFETCH(int, expected);
|
||||||
QFETCH(bool, caseSensitive);
|
QFETCH(bool, caseSensitive);
|
||||||
CREATE_REF(needle);
|
CREATE_VIEW(needle);
|
||||||
|
|
||||||
Qt::CaseSensitivity cs = (caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
Qt::CaseSensitivity cs = (caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||||
|
|
||||||
QCOMPARE(haystack.lastIndexOf(needle, from, cs), expected);
|
QCOMPARE(haystack.lastIndexOf(needle, from, cs), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(ref, from, cs), expected);
|
QCOMPARE(haystack.lastIndexOf(view, from, cs), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from, cs), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from, cs), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from, cs), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from, cs), expected);
|
||||||
|
|
||||||
@ -1690,19 +1658,19 @@ void tst_QString::lastIndexOf()
|
|||||||
|
|
||||||
if (cs == Qt::CaseSensitive) {
|
if (cs == Qt::CaseSensitive) {
|
||||||
QCOMPARE(haystack.lastIndexOf(needle, from), expected);
|
QCOMPARE(haystack.lastIndexOf(needle, from), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(ref, from), expected);
|
QCOMPARE(haystack.lastIndexOf(view, from), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from), expected);
|
||||||
if (from == -1) {
|
if (from == -1) {
|
||||||
QCOMPARE(haystack.lastIndexOf(needle), expected);
|
QCOMPARE(haystack.lastIndexOf(needle), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(ref), expected);
|
QCOMPARE(haystack.lastIndexOf(view), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1()), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1()), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data()), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data()), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needle.size() == 1) {
|
if (needle.size() == 1) {
|
||||||
QCOMPARE(haystack.lastIndexOf(needle.at(0), from), expected);
|
QCOMPARE(haystack.lastIndexOf(needle.at(0), from), expected);
|
||||||
QCOMPARE(haystack.lastIndexOf(ref.at(0), from), expected);
|
QCOMPARE(haystack.lastIndexOf(view.at(0), from), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1738,13 +1706,10 @@ void tst_QString::count()
|
|||||||
QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object");
|
QTest::ignoreMessage(QtWarningMsg, "QString::count: invalid QRegularExpression object");
|
||||||
QCOMPARE(a.count(QRegularExpression("invalid regex\\")), 0);
|
QCOMPARE(a.count(QRegularExpression("invalid regex\\")), 0);
|
||||||
|
|
||||||
CREATE_REF(QLatin1String("FG"));
|
CREATE_VIEW(QLatin1String("FG"));
|
||||||
QCOMPARE(a.count(ref),2);
|
QCOMPARE(a.count(view),2);
|
||||||
QCOMPARE(a.count(ref,Qt::CaseInsensitive),3);
|
QCOMPARE(a.count(view,Qt::CaseInsensitive),3);
|
||||||
QCOMPARE(a.count( QStringRef(), Qt::CaseInsensitive), 16);
|
QCOMPARE(a.count( QStringView(), Qt::CaseInsensitive), 16);
|
||||||
QStringRef emptyRef(&a, 0, 0);
|
|
||||||
QCOMPARE(a.count( emptyRef, Qt::CaseInsensitive), 16);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::contains()
|
void tst_QString::contains()
|
||||||
@ -1814,12 +1779,10 @@ void tst_QString::contains()
|
|||||||
QVERIFY(!a.contains(QRegularExpression("ZZZ"), 0));
|
QVERIFY(!a.contains(QRegularExpression("ZZZ"), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE_REF(QLatin1String("FG"));
|
CREATE_VIEW(QLatin1String("FG"));
|
||||||
QVERIFY(a.contains(ref));
|
QVERIFY(a.contains(view));
|
||||||
QVERIFY(a.contains(ref, Qt::CaseInsensitive));
|
QVERIFY(a.contains(view, Qt::CaseInsensitive));
|
||||||
QVERIFY(a.contains( QStringRef(), Qt::CaseInsensitive));
|
QVERIFY(a.contains( QStringView(), Qt::CaseInsensitive));
|
||||||
QStringRef emptyRef(&a, 0, 0);
|
|
||||||
QVERIFY(a.contains(emptyRef, Qt::CaseInsensitive));
|
|
||||||
|
|
||||||
QTest::ignoreMessage(QtWarningMsg, "QString::contains: invalid QRegularExpression object");
|
QTest::ignoreMessage(QtWarningMsg, "QString::contains: invalid QRegularExpression object");
|
||||||
QVERIFY(!a.contains(QRegularExpression("invalid regex\\")));
|
QVERIFY(!a.contains(QRegularExpression("invalid regex\\")));
|
||||||
@ -1844,25 +1807,6 @@ void tst_QString::left()
|
|||||||
QCOMPARE(l.left(100), l);
|
QCOMPARE(l.left(100), l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::leftRef()
|
|
||||||
{
|
|
||||||
QString a;
|
|
||||||
a="ABCDEFGHIEfGEFG"; // 15 chars
|
|
||||||
QCOMPARE(a.leftRef(3).toString(), QLatin1String("ABC"));
|
|
||||||
|
|
||||||
QVERIFY(a.leftRef(0).toString().isEmpty());
|
|
||||||
QCOMPARE(a.leftRef(0).toString(), QLatin1String(""));
|
|
||||||
|
|
||||||
QString n;
|
|
||||||
QVERIFY(n.leftRef(3).toString().isEmpty());
|
|
||||||
QVERIFY(n.leftRef(0).toString().isEmpty());
|
|
||||||
QVERIFY(n.leftRef(0).toString().isEmpty());
|
|
||||||
|
|
||||||
QString l = "Left";
|
|
||||||
QCOMPARE(l.leftRef(-1).toString(), l);
|
|
||||||
QCOMPARE(l.leftRef(100).toString(), l);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::right()
|
void tst_QString::right()
|
||||||
{
|
{
|
||||||
QString a;
|
QString a;
|
||||||
@ -1879,22 +1823,6 @@ void tst_QString::right()
|
|||||||
QCOMPARE(r.right(100), r);
|
QCOMPARE(r.right(100), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::rightRef()
|
|
||||||
{
|
|
||||||
QString a;
|
|
||||||
a="ABCDEFGHIEfGEFG"; // 15 chars
|
|
||||||
QCOMPARE(a.rightRef(3).toString(), QLatin1String("EFG"));
|
|
||||||
QCOMPARE(a.rightRef(0).toString(), QLatin1String(""));
|
|
||||||
|
|
||||||
QString n;
|
|
||||||
QVERIFY(n.rightRef(3).toString().isEmpty());
|
|
||||||
QVERIFY(n.rightRef(0).toString().isEmpty());
|
|
||||||
|
|
||||||
QString r = "Right";
|
|
||||||
QCOMPARE(r.rightRef(-1).toString(), r);
|
|
||||||
QCOMPARE(r.rightRef(100).toString(), r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::mid()
|
void tst_QString::mid()
|
||||||
{
|
{
|
||||||
QString a;
|
QString a;
|
||||||
@ -1974,132 +1902,6 @@ void tst_QString::mid()
|
|||||||
QCOMPARE(x.mid(-1, -1), x);
|
QCOMPARE(x.mid(-1, -1), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::midRef()
|
|
||||||
{
|
|
||||||
QString a;
|
|
||||||
a="ABCDEFGHIEfGEFG"; // 15 chars
|
|
||||||
|
|
||||||
QCOMPARE(a.midRef(3,3).toString(), QLatin1String("DEF"));
|
|
||||||
QCOMPARE(a.midRef(0,0).toString(), QLatin1String(""));
|
|
||||||
QVERIFY(!a.midRef(15,0).toString().isNull());
|
|
||||||
QVERIFY(a.midRef(15,0).toString().isEmpty());
|
|
||||||
QVERIFY(!a.midRef(15,1).toString().isNull());
|
|
||||||
QVERIFY(a.midRef(15,1).toString().isEmpty());
|
|
||||||
QVERIFY(a.midRef(9999).toString().isEmpty());
|
|
||||||
QVERIFY(a.midRef(9999,1).toString().isEmpty());
|
|
||||||
|
|
||||||
QCOMPARE(a.midRef(-1, 6), a.midRef(0, 5));
|
|
||||||
QVERIFY(a.midRef(-100, 6).isEmpty());
|
|
||||||
QVERIFY(a.midRef(INT_MIN, 0).isEmpty());
|
|
||||||
QCOMPARE(a.midRef(INT_MIN, -1).toString(), a);
|
|
||||||
QVERIFY(a.midRef(INT_MIN, INT_MAX).isNull());
|
|
||||||
QVERIFY(a.midRef(INT_MIN + 1, INT_MAX).isEmpty());
|
|
||||||
QCOMPARE(a.midRef(INT_MIN + 2, INT_MAX), a.leftRef(1));
|
|
||||||
QCOMPARE(a.midRef(INT_MIN + a.size() + 1, INT_MAX).toString(), a);
|
|
||||||
QVERIFY(a.midRef(INT_MAX).isNull());
|
|
||||||
QVERIFY(a.midRef(INT_MAX, INT_MAX).isNull());
|
|
||||||
QCOMPARE(a.midRef(-5, INT_MAX).toString(), a);
|
|
||||||
QCOMPARE(a.midRef(-1, INT_MAX).toString(), a);
|
|
||||||
QCOMPARE(a.midRef(0, INT_MAX).toString(), a);
|
|
||||||
QCOMPARE(a.midRef(1, INT_MAX).toString(), QString("BCDEFGHIEfGEFG"));
|
|
||||||
QCOMPARE(a.midRef(5, INT_MAX).toString(), QString("FGHIEfGEFG"));
|
|
||||||
QVERIFY(a.midRef(20, INT_MAX).isNull());
|
|
||||||
QCOMPARE(a.midRef(-1, -1).toString(), a);
|
|
||||||
|
|
||||||
QString n;
|
|
||||||
QVERIFY(n.midRef(3,3).toString().isEmpty());
|
|
||||||
QVERIFY(n.midRef(0,0).toString().isEmpty());
|
|
||||||
QVERIFY(n.midRef(9999,0).toString().isEmpty());
|
|
||||||
QVERIFY(n.midRef(9999,1).toString().isEmpty());
|
|
||||||
|
|
||||||
QVERIFY(n.midRef(-1, 6).isNull());
|
|
||||||
QVERIFY(n.midRef(-100, 6).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN, 0).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN, -1).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN + 1, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN + 2, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MIN + n.size() + 1, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(INT_MAX, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(-5, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(-1, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(0, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(1, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(5, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(20, INT_MAX).isNull());
|
|
||||||
QVERIFY(n.midRef(-1, -1).isNull());
|
|
||||||
|
|
||||||
QString x = "Nine pineapples";
|
|
||||||
QCOMPARE(x.midRef(5, 4).toString(), QString("pine"));
|
|
||||||
QCOMPARE(x.midRef(5).toString(), QString("pineapples"));
|
|
||||||
|
|
||||||
QCOMPARE(x.midRef(-1, 6), x.midRef(0, 5));
|
|
||||||
QVERIFY(x.midRef(-100, 6).isEmpty());
|
|
||||||
QVERIFY(x.midRef(INT_MIN, 0).isEmpty());
|
|
||||||
QCOMPARE(x.midRef(INT_MIN, -1).toString(), x);
|
|
||||||
QVERIFY(x.midRef(INT_MIN, INT_MAX).isNull());
|
|
||||||
QVERIFY(x.midRef(INT_MIN + 1, INT_MAX).isEmpty());
|
|
||||||
QCOMPARE(x.midRef(INT_MIN + 2, INT_MAX), x.leftRef(1));
|
|
||||||
QCOMPARE(x.midRef(INT_MIN + x.size() + 1, INT_MAX).toString(), x);
|
|
||||||
QVERIFY(x.midRef(INT_MAX).isNull());
|
|
||||||
QVERIFY(x.midRef(INT_MAX, INT_MAX).isNull());
|
|
||||||
QCOMPARE(x.midRef(-5, INT_MAX).toString(), x);
|
|
||||||
QCOMPARE(x.midRef(-1, INT_MAX).toString(), x);
|
|
||||||
QCOMPARE(x.midRef(0, INT_MAX).toString(), x);
|
|
||||||
QCOMPARE(x.midRef(1, INT_MAX).toString(), QString("ine pineapples"));
|
|
||||||
QCOMPARE(x.midRef(5, INT_MAX).toString(), QString("pineapples"));
|
|
||||||
QVERIFY(x.midRef(20, INT_MAX).isNull());
|
|
||||||
QCOMPARE(x.midRef(-1, -1).toString(), x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::stringRef()
|
|
||||||
{
|
|
||||||
QString a;
|
|
||||||
a="ABCDEFGHIEfGEFG"; // 15 chars
|
|
||||||
|
|
||||||
QVERIFY(QStringRef(&a, 0, 0) == (QString)"");
|
|
||||||
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) == (QString)"DEF");
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) == QLatin1String("DEF"));
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) == "DEF");
|
|
||||||
QVERIFY((QString)"DEF" == QStringRef(&a, 3, 3));
|
|
||||||
QVERIFY(QLatin1String("DEF") == QStringRef(&a, 3, 3));
|
|
||||||
QVERIFY("DEF" == QStringRef(&a, 3, 3));
|
|
||||||
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) != (QString)"DE");
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) != QLatin1String("DE"));
|
|
||||||
QVERIFY(QStringRef(&a, 3, 3) != "DE");
|
|
||||||
QVERIFY((QString)"DE" != QStringRef(&a, 3, 3));
|
|
||||||
QVERIFY(QLatin1String("DE") != QStringRef(&a, 3, 3));
|
|
||||||
QVERIFY("DE" != QStringRef(&a, 3, 3));
|
|
||||||
|
|
||||||
QString s_alpha("alpha");
|
|
||||||
QString s_beta("beta");
|
|
||||||
QStringRef alpha(&s_alpha);
|
|
||||||
QStringRef beta(&s_beta);
|
|
||||||
|
|
||||||
QVERIFY(alpha < beta);
|
|
||||||
QVERIFY(alpha <= beta);
|
|
||||||
QVERIFY(alpha <= alpha);
|
|
||||||
QVERIFY(beta > alpha);
|
|
||||||
QVERIFY(beta >= alpha);
|
|
||||||
QVERIFY(beta >= beta);
|
|
||||||
|
|
||||||
QString s_alpha2("alpha");
|
|
||||||
|
|
||||||
QMap<QStringRef, QString> map;
|
|
||||||
map.insert(alpha, "alpha");
|
|
||||||
map.insert(beta, "beta");
|
|
||||||
QVERIFY(alpha == map.value(QStringRef(&s_alpha2)));
|
|
||||||
|
|
||||||
QHash<QStringRef, QString> hash;
|
|
||||||
hash.insert(alpha, "alpha");
|
|
||||||
hash.insert(beta, "beta");
|
|
||||||
|
|
||||||
QVERIFY(alpha == hash.value(QStringRef(&s_alpha2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::leftJustified()
|
void tst_QString::leftJustified()
|
||||||
{
|
{
|
||||||
QString a;
|
QString a;
|
||||||
@ -3843,13 +3645,12 @@ void tst_QString::startsWith()
|
|||||||
QVERIFY( !a.startsWith(QChar(), Qt::CaseSensitive) );
|
QVERIFY( !a.startsWith(QChar(), Qt::CaseSensitive) );
|
||||||
QVERIFY( !a.startsWith(QLatin1Char(0), Qt::CaseSensitive) );
|
QVERIFY( !a.startsWith(QLatin1Char(0), Qt::CaseSensitive) );
|
||||||
|
|
||||||
#define TEST_REF_STARTS_WITH(string, yes) { CREATE_REF(string); QCOMPARE(a.startsWith(ref), yes); }
|
#define TEST_VIEW_STARTS_WITH(string, yes) { CREATE_VIEW(string); QCOMPARE(a.startsWith(view), yes); }
|
||||||
|
TEST_VIEW_STARTS_WITH("A", true);
|
||||||
TEST_REF_STARTS_WITH("A", true);
|
TEST_VIEW_STARTS_WITH("AB", true);
|
||||||
TEST_REF_STARTS_WITH("AB", true);
|
TEST_VIEW_STARTS_WITH("C", false);
|
||||||
TEST_REF_STARTS_WITH("C", false);
|
TEST_VIEW_STARTS_WITH("ABCDEF", false);
|
||||||
TEST_REF_STARTS_WITH("ABCDEF", false);
|
#undef TEST_VIEW_STARTS_WITH
|
||||||
#undef TEST_REF_STARTS_WITH
|
|
||||||
|
|
||||||
a = "";
|
a = "";
|
||||||
QVERIFY( a.startsWith("") );
|
QVERIFY( a.startsWith("") );
|
||||||
@ -3951,16 +3752,14 @@ void tst_QString::endsWith()
|
|||||||
QVERIFY( !a.endsWith(QChar(), Qt::CaseSensitive) );
|
QVERIFY( !a.endsWith(QChar(), Qt::CaseSensitive) );
|
||||||
QVERIFY( !a.endsWith(QLatin1Char(0), Qt::CaseSensitive) );
|
QVERIFY( !a.endsWith(QLatin1Char(0), Qt::CaseSensitive) );
|
||||||
|
|
||||||
|
#define TEST_VIEW_ENDS_WITH(string, yes) { CREATE_VIEW(string); QCOMPARE(a.endsWith(view), yes); }
|
||||||
#define TEST_REF_ENDS_WITH(string, yes) { CREATE_REF(string); QCOMPARE(a.endsWith(ref), yes); }
|
TEST_VIEW_ENDS_WITH(QLatin1String("B"), true);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String("B"), true);
|
TEST_VIEW_ENDS_WITH(QLatin1String("AB"), true);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String("AB"), true);
|
TEST_VIEW_ENDS_WITH(QLatin1String("C"), false);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String("C"), false);
|
TEST_VIEW_ENDS_WITH(QLatin1String("ABCDEF"), false);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String("ABCDEF"), false);
|
TEST_VIEW_ENDS_WITH(QLatin1String(""), true);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String(""), true);
|
TEST_VIEW_ENDS_WITH(QLatin1String(0), true);
|
||||||
TEST_REF_ENDS_WITH(QLatin1String(0), true);
|
#undef TEST_VIEW_ENDS_WITH
|
||||||
|
|
||||||
#undef TEST_REF_STARTS_WITH
|
|
||||||
|
|
||||||
a = "";
|
a = "";
|
||||||
QVERIFY( a.endsWith("") );
|
QVERIFY( a.endsWith("") );
|
||||||
@ -4133,20 +3932,6 @@ void tst_QString::utf8()
|
|||||||
QCOMPARE(res.toUtf8(), utf8);
|
QCOMPARE(res.toUtf8(), utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::stringRef_utf8_data()
|
|
||||||
{
|
|
||||||
utf8_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::stringRef_utf8()
|
|
||||||
{
|
|
||||||
QFETCH( QByteArray, utf8 );
|
|
||||||
QFETCH( QString, res );
|
|
||||||
|
|
||||||
QStringRef ref(&res, 0, res.length());
|
|
||||||
QCOMPARE( utf8, QByteArray(ref.toUtf8()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::fromUtf8_data()
|
void tst_QString::fromUtf8_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QByteArray>("utf8");
|
QTest::addColumn<QByteArray>("utf8");
|
||||||
@ -4420,20 +4205,6 @@ void tst_QString::nullFromLocal8Bit()
|
|||||||
QVERIFY(a.isEmpty());
|
QVERIFY(a.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::stringRef_local8Bit_data()
|
|
||||||
{
|
|
||||||
local8Bit_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::stringRef_local8Bit()
|
|
||||||
{
|
|
||||||
QFETCH(QString, local8Bit);
|
|
||||||
QFETCH(QByteArray, result);
|
|
||||||
|
|
||||||
QStringRef ref(&local8Bit, 0, local8Bit.length());
|
|
||||||
QCOMPARE(ref.toLocal8Bit(), QByteArray(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::fromLatin1Roundtrip_data()
|
void tst_QString::fromLatin1Roundtrip_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QByteArray>("latin1");
|
QTest::addColumn<QByteArray>("latin1");
|
||||||
@ -4545,38 +4316,6 @@ void tst_QString::toLatin1Roundtrip()
|
|||||||
s.clear();
|
s.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::stringRef_toLatin1Roundtrip_data()
|
|
||||||
{
|
|
||||||
toLatin1Roundtrip_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::stringRef_toLatin1Roundtrip()
|
|
||||||
{
|
|
||||||
QFETCH(QByteArray, latin1);
|
|
||||||
QFETCH(QString, unicodesrc);
|
|
||||||
QFETCH(QString, unicodedst);
|
|
||||||
|
|
||||||
// Qt Test safety check:
|
|
||||||
QCOMPARE(latin1.isNull(), unicodesrc.isNull());
|
|
||||||
QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
|
|
||||||
QCOMPARE(latin1.length(), unicodesrc.length());
|
|
||||||
QCOMPARE(latin1.isNull(), unicodedst.isNull());
|
|
||||||
QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
|
|
||||||
QCOMPARE(latin1.length(), unicodedst.length());
|
|
||||||
|
|
||||||
if (!latin1.isEmpty())
|
|
||||||
while (latin1.length() < 128) {
|
|
||||||
latin1 += latin1;
|
|
||||||
unicodesrc += unicodesrc;
|
|
||||||
unicodedst += unicodedst;
|
|
||||||
}
|
|
||||||
|
|
||||||
// toLatin1
|
|
||||||
QStringRef src(&unicodesrc, 0, unicodesrc.length());
|
|
||||||
QCOMPARE(src.toLatin1().length(), latin1.length());
|
|
||||||
QCOMPARE(src.toLatin1(), latin1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::fromLatin1()
|
void tst_QString::fromLatin1()
|
||||||
{
|
{
|
||||||
QString a;
|
QString a;
|
||||||
@ -5602,9 +5341,6 @@ void tst_QString::localeAwareCompare()
|
|||||||
QFETCH(QString, s2);
|
QFETCH(QString, s2);
|
||||||
QFETCH(int, result);
|
QFETCH(int, result);
|
||||||
|
|
||||||
QStringRef r1(&s1, 0, s1.length());
|
|
||||||
QStringRef r2(&s2, 0, s2.length());
|
|
||||||
|
|
||||||
if (!locale.isEmpty()) {
|
if (!locale.isEmpty()) {
|
||||||
#if defined (Q_OS_DARWIN) || QT_CONFIG(icu)
|
#if defined (Q_OS_DARWIN) || QT_CONFIG(icu)
|
||||||
QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
|
QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
|
||||||
@ -5640,33 +5376,6 @@ void tst_QString::localeAwareCompare()
|
|||||||
QVERIFY(testres == 0);
|
QVERIFY(testres == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
testres = QString::localeAwareCompare(s1, r2);
|
|
||||||
if (result < 0) {
|
|
||||||
QVERIFY(testres < 0);
|
|
||||||
} else if (result > 0) {
|
|
||||||
QVERIFY(testres > 0);
|
|
||||||
} else {
|
|
||||||
QVERIFY(testres == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
testres = QStringRef::localeAwareCompare(r1, r2);
|
|
||||||
if (result < 0) {
|
|
||||||
QVERIFY(testres < 0);
|
|
||||||
} else if (result > 0) {
|
|
||||||
QVERIFY(testres > 0);
|
|
||||||
} else {
|
|
||||||
QVERIFY(testres == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
testres = QStringRef::localeAwareCompare(r2, r1);
|
|
||||||
if (result > 0) {
|
|
||||||
QVERIFY(testres < 0);
|
|
||||||
} else if (result < 0) {
|
|
||||||
QVERIFY(testres > 0);
|
|
||||||
} else {
|
|
||||||
QVERIFY(testres == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!locale.isEmpty())
|
if (!locale.isEmpty())
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
}
|
}
|
||||||
@ -5714,14 +5423,6 @@ template<> struct StringSplitWrapper<QString>
|
|||||||
QStringList split(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const { return string.split(sep, behavior); }
|
QStringList split(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const { return string.split(sep, behavior); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct StringSplitWrapper<QStringRef>
|
|
||||||
{
|
|
||||||
const QString &string;
|
|
||||||
QList<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
|
|
||||||
QList<QStringRef> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
|
|
||||||
QList<QStringRef> split(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const { return string.splitRef(sep, behavior); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<> struct StringSplitWrapper<QStringView>
|
template<> struct StringSplitWrapper<QStringView>
|
||||||
{
|
{
|
||||||
const QString &string;
|
const QString &string;
|
||||||
@ -5743,16 +5444,6 @@ static bool operator==(const QList<QStringView> &result, const QStringList &expe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool operator ==(const QStringList &left, const QList<QStringRef> &right)
|
|
||||||
{
|
|
||||||
if (left.size() != right.size())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return std::equal(left.constBegin(), left.constEnd(), right.constBegin());
|
|
||||||
}
|
|
||||||
static inline bool operator ==(const QList<QStringRef> &left, const QStringList &right) { return right == left; }
|
|
||||||
|
|
||||||
template<class List>
|
template<class List>
|
||||||
void tst_QString::split(const QString &string, const QString &sep, QStringList result)
|
void tst_QString::split(const QString &string, const QString &sep, QStringList result)
|
||||||
{
|
{
|
||||||
@ -5802,19 +5493,6 @@ void tst_QString::split()
|
|||||||
split<QList<QStringView>>(str, sep, result);
|
split<QList<QStringView>>(str, sep, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::splitRef_data()
|
|
||||||
{
|
|
||||||
split_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::splitRef()
|
|
||||||
{
|
|
||||||
QFETCH(QString, str);
|
|
||||||
QFETCH(QString, sep);
|
|
||||||
QFETCH(QStringList, result);
|
|
||||||
split<QList<QStringRef> >(str, sep, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::split_regularexpression_data()
|
void tst_QString::split_regularexpression_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("string");
|
QTest::addColumn<QString>("string");
|
||||||
@ -5858,19 +5536,6 @@ void tst_QString::split_regularexpression()
|
|||||||
split_regexp<QList<QStringView>, QRegularExpression>(string, pattern, result);
|
split_regexp<QList<QStringView>, QRegularExpression>(string, pattern, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::splitRef_regularexpression_data()
|
|
||||||
{
|
|
||||||
split_regularexpression_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::splitRef_regularexpression()
|
|
||||||
{
|
|
||||||
QFETCH(QString, string);
|
|
||||||
QFETCH(QString, pattern);
|
|
||||||
QFETCH(QStringList, result);
|
|
||||||
split_regexp<QList<QStringRef>, QRegularExpression>(string, pattern, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::fromUtf16_data()
|
void tst_QString::fromUtf16_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("ucs2");
|
QTest::addColumn<QString>("ucs2");
|
||||||
@ -6215,8 +5880,6 @@ void tst_QString::compare()
|
|||||||
QFETCH(int, csr);
|
QFETCH(int, csr);
|
||||||
QFETCH(int, cir);
|
QFETCH(int, cir);
|
||||||
|
|
||||||
QStringRef r1(&s1, 0, s1.length());
|
|
||||||
QStringRef r2(&s2, 0, s2.length());
|
|
||||||
QByteArray s1_8 = s1.toUtf8();
|
QByteArray s1_8 = s1.toUtf8();
|
||||||
QByteArray s2_8 = s2.toUtf8();
|
QByteArray s2_8 = s2.toUtf8();
|
||||||
|
|
||||||
@ -6224,18 +5887,11 @@ void tst_QString::compare()
|
|||||||
const QStringView v2(s2);
|
const QStringView v2(s2);
|
||||||
|
|
||||||
QCOMPARE(sign(QString::compare(s1, s2)), csr);
|
QCOMPARE(sign(QString::compare(s1, s2)), csr);
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, r2)), csr);
|
|
||||||
QCOMPARE(sign(s1.compare(s2)), csr);
|
QCOMPARE(sign(s1.compare(s2)), csr);
|
||||||
QCOMPARE(sign(s1.compare(r2)), csr);
|
|
||||||
QCOMPARE(sign(r1.compare(r2)), csr);
|
|
||||||
QCOMPARE(sign(s1.compare(v2)), csr);
|
QCOMPARE(sign(s1.compare(v2)), csr);
|
||||||
|
|
||||||
QCOMPARE(sign(s1.compare(s2, Qt::CaseSensitive)), csr);
|
QCOMPARE(sign(s1.compare(s2, Qt::CaseSensitive)), csr);
|
||||||
QCOMPARE(sign(s1.compare(s2, Qt::CaseInsensitive)), cir);
|
QCOMPARE(sign(s1.compare(s2, Qt::CaseInsensitive)), cir);
|
||||||
QCOMPARE(sign(s1.compare(r2, Qt::CaseSensitive)), csr);
|
|
||||||
QCOMPARE(sign(s1.compare(r2, Qt::CaseInsensitive)), cir);
|
|
||||||
QCOMPARE(sign(r1.compare(r2, Qt::CaseSensitive)), csr);
|
|
||||||
QCOMPARE(sign(r1.compare(r2, Qt::CaseInsensitive)), cir);
|
|
||||||
QCOMPARE(sign(s1.compare(v2, Qt::CaseSensitive)), csr);
|
QCOMPARE(sign(s1.compare(v2, Qt::CaseSensitive)), csr);
|
||||||
QCOMPARE(sign(s1.compare(v2, Qt::CaseInsensitive)), cir);
|
QCOMPARE(sign(s1.compare(v2, Qt::CaseInsensitive)), cir);
|
||||||
QCOMPARE(sign(QtPrivate::compareStringsUtf8(s1_8, s1_8.size(), v2, Qt::CaseSensitive)), csr);
|
QCOMPARE(sign(QtPrivate::compareStringsUtf8(s1_8, s1_8.size(), v2, Qt::CaseSensitive)), csr);
|
||||||
@ -6245,35 +5901,22 @@ void tst_QString::compare()
|
|||||||
|
|
||||||
QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseSensitive)), csr);
|
QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseSensitive)), csr);
|
||||||
QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseInsensitive)), cir);
|
QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseInsensitive)), cir);
|
||||||
QCOMPARE(sign(QString::compare(s1, r2, Qt::CaseSensitive)), csr);
|
|
||||||
QCOMPARE(sign(QString::compare(s1, r2, Qt::CaseInsensitive)), cir);
|
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseSensitive)), csr);
|
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseInsensitive)), cir);
|
|
||||||
|
|
||||||
if (csr == 0) {
|
if (csr == 0)
|
||||||
QVERIFY(qHash(s1) == qHash(s2));
|
QVERIFY(qHash(s1) == qHash(s2));
|
||||||
QVERIFY(qHash(s1) == qHash(r2));
|
|
||||||
QVERIFY(qHash(r1) == qHash(s2));
|
|
||||||
QVERIFY(qHash(r1) == qHash(r2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cir) {
|
if (!cir)
|
||||||
QCOMPARE(s1.toCaseFolded(), s2.toCaseFolded());
|
QCOMPARE(s1.toCaseFolded(), s2.toCaseFolded());
|
||||||
}
|
|
||||||
|
|
||||||
if (isLatin(s2)) {
|
if (isLatin(s2)) {
|
||||||
QVERIFY(QtPrivate::isLatin1(s2));
|
QVERIFY(QtPrivate::isLatin1(s2));
|
||||||
QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()))), csr);
|
QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()))), csr);
|
||||||
QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir);
|
QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir);
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()))), csr);
|
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir);
|
|
||||||
QByteArray l1 = s2.toLatin1();
|
QByteArray l1 = s2.toLatin1();
|
||||||
l1 += "x";
|
l1 += "x";
|
||||||
QLatin1String l1str(l1.constData(), l1.size() - 1);
|
QLatin1String l1str(l1.constData(), l1.size() - 1);
|
||||||
QCOMPARE(sign(QString::compare(s1, l1str)), csr);
|
QCOMPARE(sign(QString::compare(s1, l1str)), csr);
|
||||||
QCOMPARE(sign(QString::compare(s1, l1str, Qt::CaseInsensitive)), cir);
|
QCOMPARE(sign(QString::compare(s1, l1str, Qt::CaseInsensitive)), cir);
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, l1str)), csr);
|
|
||||||
QCOMPARE(sign(QStringRef::compare(r1, l1str, Qt::CaseInsensitive)), cir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLatin(s1)) {
|
if (isLatin(s1)) {
|
||||||
@ -6508,37 +6151,6 @@ void tst_QString::repeated_data() const
|
|||||||
<< 4;
|
<< 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::compareRef()
|
|
||||||
{
|
|
||||||
QString a = "ABCDEFGH";
|
|
||||||
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QLatin1String("BC")), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QLatin1String("BCD")) < 0);
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QLatin1String("Bc"), Qt::CaseInsensitive), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QLatin1String("bCD"), Qt::CaseInsensitive) < 0);
|
|
||||||
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QString::fromLatin1("BC")), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QString::fromLatin1("BCD")) < 0);
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QString::fromLatin1("Bc"), Qt::CaseInsensitive), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QString::fromLatin1("bCD"), Qt::CaseInsensitive) < 0);
|
|
||||||
|
|
||||||
QCOMPARE(QString::fromLatin1("BC").compare(QStringRef(&a, 1, 2)), 0);
|
|
||||||
QVERIFY(QString::fromLatin1("BCD").compare(QStringRef(&a, 1, 2)) > 0);
|
|
||||||
QCOMPARE(QString::fromLatin1("Bc").compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
|
|
||||||
QVERIFY(QString::fromLatin1("bCD").compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive) > 0);
|
|
||||||
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 2)), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 3)) < 0);
|
|
||||||
QCOMPARE(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
|
|
||||||
QVERIFY(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0);
|
|
||||||
|
|
||||||
QString a2 = "ABCDEFGh";
|
|
||||||
QCOMPARE(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 2)), 0);
|
|
||||||
QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3)) < 0);
|
|
||||||
QCOMPARE(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
|
|
||||||
QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QString::arg_locale()
|
void tst_QString::arg_locale()
|
||||||
{
|
{
|
||||||
QLocale l(QLocale::English, QLocale::UnitedKingdom);
|
QLocale l(QLocale::English, QLocale::UnitedKingdom);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,6 @@
|
|||||||
template <typename T> QString toQString(const T &t);
|
template <typename T> QString toQString(const T &t);
|
||||||
|
|
||||||
template <> QString toQString(const QString &s) { return s; }
|
template <> QString toQString(const QString &s) { return s; }
|
||||||
template <> QString toQString(const QStringRef &r) { return r.toString(); }
|
|
||||||
template <> QString toQString(const QStringView &v) { return v.toString(); }
|
template <> QString toQString(const QStringView &v) { return v.toString(); }
|
||||||
template <> QString toQString(const QLatin1String &l) { return l; }
|
template <> QString toQString(const QLatin1String &l) { return l; }
|
||||||
template <> QString toQString(const QLatin1Char &l) { return QChar(l); }
|
template <> QString toQString(const QLatin1Char &l) { return QChar(l); }
|
||||||
@ -84,8 +83,7 @@ void runScenario()
|
|||||||
// strings default to utf8.
|
// strings default to utf8.
|
||||||
QLatin1String l1string(LITERAL);
|
QLatin1String l1string(LITERAL);
|
||||||
QString string(l1string);
|
QString string(l1string);
|
||||||
QStringRef stringref(&string, 2, 10);
|
QStringView stringview = QStringView{ string }.mid(2, 10);
|
||||||
QStringView stringview(stringref);
|
|
||||||
QLatin1Char lchar('c');
|
QLatin1Char lchar('c');
|
||||||
QChar qchar(lchar);
|
QChar qchar(lchar);
|
||||||
QChar::SpecialCharacter special(QChar::Nbsp);
|
QChar::SpecialCharacter special(QChar::Nbsp);
|
||||||
@ -109,7 +107,6 @@ void runScenario()
|
|||||||
|
|
||||||
CHECK(P, l1string, l1string);
|
CHECK(P, l1string, l1string);
|
||||||
CHECK(P, l1string, string);
|
CHECK(P, l1string, string);
|
||||||
CHECK(P, l1string, stringref);
|
|
||||||
CHECK(Q, l1string, stringview);
|
CHECK(Q, l1string, stringview);
|
||||||
CHECK(P, l1string, lchar);
|
CHECK(P, l1string, lchar);
|
||||||
CHECK(P, l1string, qchar);
|
CHECK(P, l1string, qchar);
|
||||||
@ -120,7 +117,6 @@ void runScenario()
|
|||||||
CHECK(Q, l1string, u16charstar);
|
CHECK(Q, l1string, u16charstar);
|
||||||
|
|
||||||
CHECK(P, string, string);
|
CHECK(P, string, string);
|
||||||
CHECK(P, string, stringref);
|
|
||||||
CHECK(Q, string, stringview);
|
CHECK(Q, string, stringview);
|
||||||
CHECK(P, string, lchar);
|
CHECK(P, string, lchar);
|
||||||
CHECK(P, string, qchar);
|
CHECK(P, string, qchar);
|
||||||
@ -130,16 +126,6 @@ void runScenario()
|
|||||||
CHECK(Q, string, u16chararray);
|
CHECK(Q, string, u16chararray);
|
||||||
CHECK(Q, string, u16charstar);
|
CHECK(Q, string, u16charstar);
|
||||||
|
|
||||||
CHECK(P, stringref, stringref);
|
|
||||||
CHECK(Q, stringref, stringview);
|
|
||||||
CHECK(P, stringref, lchar);
|
|
||||||
CHECK(P, stringref, qchar);
|
|
||||||
CHECK(P, stringref, special);
|
|
||||||
CHECK(P, stringref, QStringLiteral(LITERAL));
|
|
||||||
CHECK(Q, stringref, u16char);
|
|
||||||
CHECK(Q, stringref, u16chararray);
|
|
||||||
CHECK(Q, stringref, u16charstar);
|
|
||||||
|
|
||||||
CHECK(Q, stringview, stringview);
|
CHECK(Q, stringview, stringview);
|
||||||
CHECK(Q, stringview, lchar);
|
CHECK(Q, stringview, lchar);
|
||||||
CHECK(Q, stringview, qchar);
|
CHECK(Q, stringview, qchar);
|
||||||
@ -191,7 +177,7 @@ void runScenario()
|
|||||||
toQByteArray(a1).append(toQByteArray(a2))) \
|
toQByteArray(a1).append(toQByteArray(a2))) \
|
||||||
/* end */
|
/* end */
|
||||||
|
|
||||||
QByteArray bytearray = stringref.toUtf8();
|
QByteArray bytearray = stringview.toUtf8();
|
||||||
char *charstar = bytearray.data();
|
char *charstar = bytearray.data();
|
||||||
char chararray[3] = { 'H', 'i', '\0' };
|
char chararray[3] = { 'H', 'i', '\0' };
|
||||||
const char constchararray[3] = { 'H', 'i', '\0' };
|
const char constchararray[3] = { 'H', 'i', '\0' };
|
||||||
@ -224,9 +210,9 @@ void runScenario()
|
|||||||
QString r;
|
QString r;
|
||||||
|
|
||||||
// self-assignment:
|
// self-assignment:
|
||||||
r = stringref.toString();
|
r = stringview.toString();
|
||||||
r = lchar + r;
|
r = lchar + r;
|
||||||
QCOMPARE(r, QString(lchar P stringref));
|
QCOMPARE(r, QString(lchar P stringview));
|
||||||
|
|
||||||
#ifdef Q_COMPILER_UNICODE_STRINGS
|
#ifdef Q_COMPILER_UNICODE_STRINGS
|
||||||
r = QStringLiteral(UNICODE_LITERAL);
|
r = QStringLiteral(UNICODE_LITERAL);
|
||||||
|
@ -55,7 +55,7 @@ void tst_QStringMatcher::qstringmatcher()
|
|||||||
void tst_QStringMatcher::caseSensitivity()
|
void tst_QStringMatcher::caseSensitivity()
|
||||||
{
|
{
|
||||||
const QString haystack = QStringLiteral("foobarFoo");
|
const QString haystack = QStringLiteral("foobarFoo");
|
||||||
const QStringRef needle = haystack.rightRef(3); // "Foo"
|
const QStringView needle = QStringView{ haystack }.right(3); // "Foo"
|
||||||
QStringMatcher matcher(needle.data(), needle.size());
|
QStringMatcher matcher(needle.data(), needle.size());
|
||||||
|
|
||||||
QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive);
|
QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive);
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
# Generated from qstringref.pro.
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
## tst_qstringref Test:
|
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
qt_add_test(tst_qstringref
|
|
||||||
SOURCES
|
|
||||||
tst_qstringref.cpp
|
|
||||||
)
|
|
@ -1,4 +0,0 @@
|
|||||||
CONFIG += testcase
|
|
||||||
TARGET = tst_qstringref
|
|
||||||
QT = core testlib
|
|
||||||
SOURCES = tst_qstringref.cpp
|
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,6 @@
|
|||||||
#include <QStringTokenizer>
|
#include <QStringTokenizer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
#include <QStringRef>
|
|
||||||
#include <QVarLengthArray>
|
#include <QVarLengthArray>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
@ -72,12 +71,6 @@ static_assert(CanConvert<const QString >::value);
|
|||||||
static_assert(CanConvert< QString&>::value);
|
static_assert(CanConvert< QString&>::value);
|
||||||
static_assert(CanConvert<const QString&>::value);
|
static_assert(CanConvert<const QString&>::value);
|
||||||
|
|
||||||
static_assert(CanConvert< QStringRef >::value);
|
|
||||||
static_assert(CanConvert<const QStringRef >::value);
|
|
||||||
static_assert(CanConvert< QStringRef&>::value);
|
|
||||||
static_assert(CanConvert<const QStringRef&>::value);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// ushort
|
// ushort
|
||||||
//
|
//
|
||||||
@ -169,7 +162,6 @@ private Q_SLOTS:
|
|||||||
void arg() const;
|
void arg() const;
|
||||||
|
|
||||||
void fromQString() const;
|
void fromQString() const;
|
||||||
void fromQStringRef() const;
|
|
||||||
|
|
||||||
void fromQCharStar() const
|
void fromQCharStar() const
|
||||||
{
|
{
|
||||||
@ -502,20 +494,6 @@ void tst_QStringView::fromQString() const
|
|||||||
conversion_tests(QString("Hello World!"));
|
conversion_tests(QString("Hello World!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QStringView::fromQStringRef() const
|
|
||||||
{
|
|
||||||
QStringRef null;
|
|
||||||
QString emptyS = "";
|
|
||||||
QStringRef empty(&emptyS);
|
|
||||||
|
|
||||||
QVERIFY( QStringView(null).isNull());
|
|
||||||
QVERIFY( QStringView(null).isEmpty());
|
|
||||||
QVERIFY( QStringView(empty).isEmpty());
|
|
||||||
QVERIFY(!QStringView(empty).isNull());
|
|
||||||
|
|
||||||
conversion_tests(QString("Hello World!").midRef(6));
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QStringView::tokenize_data() const
|
void tst_QStringView::tokenize_data() const
|
||||||
{
|
{
|
||||||
// copied from tst_QString
|
// copied from tst_QString
|
||||||
@ -571,20 +549,6 @@ void tst_QStringView::tokenize() const
|
|||||||
QCOMPARE(sv, *rit++);
|
QCOMPARE(sv, *rit++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (rvalue) QStringRef
|
|
||||||
#ifdef __cpp_deduction_guides
|
|
||||||
{
|
|
||||||
auto rit = result.cbegin();
|
|
||||||
for (auto sv : QStringTokenizer{str, sep.midRef(0)})
|
|
||||||
QCOMPARE(sv, *rit++);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
auto rit = result.cbegin();
|
|
||||||
for (auto sv : QStringView{str}.tokenize(sep.midRef(0)))
|
|
||||||
QCOMPARE(sv, *rit++);
|
|
||||||
}
|
|
||||||
|
|
||||||
// (rvalue) QChar
|
// (rvalue) QChar
|
||||||
#ifdef __cpp_deduction_guides
|
#ifdef __cpp_deduction_guides
|
||||||
if (sep.size() == 1) {
|
if (sep.size() == 1) {
|
||||||
@ -654,15 +618,6 @@ void tst_QStringView::tokenize() const
|
|||||||
QCOMPARE(result, actual);
|
QCOMPARE(result, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (rvalue) QStringRef
|
|
||||||
{
|
|
||||||
QStringList actual;
|
|
||||||
const QStringTokenizer tok{str, sep.midRef(0)};
|
|
||||||
std::ranges::transform(tok, std::back_inserter(actual),
|
|
||||||
[](auto sv) { return sv.toString(); });
|
|
||||||
QCOMPARE(result, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
// (rvalue) QChar
|
// (rvalue) QChar
|
||||||
if (sep.size() == 1) {
|
if (sep.size() == 1) {
|
||||||
QStringList actual;
|
QStringList actual;
|
||||||
@ -888,13 +843,6 @@ void tst_QStringView::overloadResolution()
|
|||||||
QStringViewOverloadResolution::test(ushortPointer);
|
QStringViewOverloadResolution::test(ushortPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
QStringRef stringRef;
|
|
||||||
QStringViewOverloadResolution::test(stringRef);
|
|
||||||
QStringViewOverloadResolution::test(qAsConst(stringRef));
|
|
||||||
QStringViewOverloadResolution::test(std::move(stringRef));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
{
|
{
|
||||||
wchar_t wchartArray[42] = {};
|
wchar_t wchartArray[42] = {};
|
||||||
|
@ -20,7 +20,6 @@ SUBDIRS = \
|
|||||||
qstringiterator \
|
qstringiterator \
|
||||||
qstringlist \
|
qstringlist \
|
||||||
qstringmatcher \
|
qstringmatcher \
|
||||||
qstringref \
|
|
||||||
qstringtokenizer \
|
qstringtokenizer \
|
||||||
qstringview \
|
qstringview \
|
||||||
qtextboundaryfinder
|
qtextboundaryfinder
|
||||||
|
@ -471,7 +471,6 @@ private Q_SLOTS:
|
|||||||
void front_back_QList() { front_back_impl<QList<qintptr>>(); }
|
void front_back_QList() { front_back_impl<QList<qintptr>>(); }
|
||||||
void front_back_QVarLengthArray() { front_back_impl<QVarLengthArray<int>>(); }
|
void front_back_QVarLengthArray() { front_back_impl<QVarLengthArray<int>>(); }
|
||||||
void front_back_QString() { front_back_impl<QString>(); }
|
void front_back_QString() { front_back_impl<QString>(); }
|
||||||
void front_back_QStringRef() { front_back_impl<QStringRef>(); }
|
|
||||||
void front_back_QStringView() { front_back_impl<QStringView>(); }
|
void front_back_QStringView() { front_back_impl<QStringView>(); }
|
||||||
void front_back_QLatin1String() { front_back_impl<QLatin1String>(); }
|
void front_back_QLatin1String() { front_back_impl<QLatin1String>(); }
|
||||||
void front_back_QByteArray() { front_back_impl<QByteArray>(); }
|
void front_back_QByteArray() { front_back_impl<QByteArray>(); }
|
||||||
@ -773,7 +772,6 @@ Container make(int size)
|
|||||||
|
|
||||||
static QString s_string = QStringLiteral("\1\2\3\4\5\6\7");
|
static QString s_string = QStringLiteral("\1\2\3\4\5\6\7");
|
||||||
|
|
||||||
template <> QStringRef make(int size) { return s_string.leftRef(size); }
|
|
||||||
template <> QStringView make(int size) { return QStringView(s_string).left(size); }
|
template <> QStringView make(int size) { return QStringView(s_string).left(size); }
|
||||||
template <> QLatin1String make(int size) { return QLatin1String("\1\2\3\4\5\6\7", size); }
|
template <> QLatin1String make(int size) { return QLatin1String("\1\2\3\4\5\6\7", size); }
|
||||||
|
|
||||||
|
@ -69,12 +69,8 @@ private Q_SLOTS:
|
|||||||
void tst_QHashFunctions::consistent()
|
void tst_QHashFunctions::consistent()
|
||||||
{
|
{
|
||||||
// QString-like
|
// QString-like
|
||||||
{
|
const QString s = QStringLiteral("abcdefghijklmnopqrstuvxyz").repeated(16);
|
||||||
const QString s = QStringLiteral("abcdefghijklmnopqrstuvxyz").repeated(16);
|
QCOMPARE(qHash(s), qHash(QStringView(s)));
|
||||||
|
|
||||||
QCOMPARE(qHash(s), qHash(QStringRef(&s)));
|
|
||||||
QCOMPARE(qHash(s), qHash(QStringView(s)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QHashFunctions::initTestCase()
|
void tst_QHashFunctions::initTestCase()
|
||||||
@ -176,10 +172,6 @@ void tst_QHashFunctions::qhash_of_empty_and_null_qstring()
|
|||||||
QCOMPARE(null, empty);
|
QCOMPARE(null, empty);
|
||||||
QCOMPARE(qHash(null, seed), qHash(empty, seed));
|
QCOMPARE(qHash(null, seed), qHash(empty, seed));
|
||||||
|
|
||||||
QStringRef nullRef, emptyRef(&empty);
|
|
||||||
QCOMPARE(nullRef, emptyRef);
|
|
||||||
QCOMPARE(qHash(nullRef, seed), qHash(emptyRef, seed));
|
|
||||||
|
|
||||||
QStringView nullView, emptyView(empty);
|
QStringView nullView, emptyView(empty);
|
||||||
QCOMPARE(nullView, emptyView);
|
QCOMPARE(nullView, emptyView);
|
||||||
QCOMPARE(qHash(nullView, seed), qHash(emptyView, seed));
|
QCOMPARE(qHash(nullView, seed), qHash(emptyView, seed));
|
||||||
|
@ -2869,12 +2869,13 @@ void tst_qmakelib::proEval()
|
|||||||
globals.environment = m_env;
|
globals.environment = m_env;
|
||||||
globals.setProperties(m_prop);
|
globals.setProperties(m_prop);
|
||||||
globals.setDirectories(m_indir, m_outdir);
|
globals.setDirectories(m_indir, m_outdir);
|
||||||
ProFile *outPro = parser.parsedProBlock(QStringRef(&out), 0, "out", 1, QMakeParser::FullGrammar);
|
ProFile *outPro =
|
||||||
|
parser.parsedProBlock(out, 0, "out", 1, QMakeParser::FullGrammar);
|
||||||
if (!outPro->isOk()) {
|
if (!outPro->isOk()) {
|
||||||
qWarning("Expected output is malformed");
|
qWarning("Expected output is malformed");
|
||||||
verified = false;
|
verified = false;
|
||||||
}
|
}
|
||||||
ProFile *pro = parser.parsedProBlock(QStringRef(&in), 0, infile, 1, QMakeParser::FullGrammar);
|
ProFile *pro = parser.parsedProBlock(in, 0, infile, 1, QMakeParser::FullGrammar);
|
||||||
QMakeEvaluator visitor(&globals, &parser, &vfs, &handler);
|
QMakeEvaluator visitor(&globals, &parser, &vfs, &handler);
|
||||||
visitor.setOutputDir(m_outdir);
|
visitor.setOutputDir(m_outdir);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -2031,7 +2031,7 @@ void tst_qmakelib::proParser()
|
|||||||
handler.setExpectedMessages(msgs.split('\n', Qt::SkipEmptyParts));
|
handler.setExpectedMessages(msgs.split('\n', Qt::SkipEmptyParts));
|
||||||
QMakeVfs vfs;
|
QMakeVfs vfs;
|
||||||
QMakeParser parser(0, &vfs, &handler);
|
QMakeParser parser(0, &vfs, &handler);
|
||||||
ProFile *pro = parser.parsedProBlock(QStringRef(&in), 0, "in", 1, QMakeParser::FullGrammar);
|
ProFile *pro = parser.parsedProBlock(QStringView{ in }, 0, "in", 1, QMakeParser::FullGrammar);
|
||||||
if (handler.printedMessages()) {
|
if (handler.printedMessages()) {
|
||||||
qWarning("Got unexpected message(s)");
|
qWarning("Got unexpected message(s)");
|
||||||
verified = false;
|
verified = false;
|
||||||
|
@ -414,7 +414,7 @@ static char **QString2cstrings(const QString &args)
|
|||||||
{
|
{
|
||||||
static QByteArrayList cache;
|
static QByteArrayList cache;
|
||||||
|
|
||||||
const auto &list = args.splitRef(' ');
|
const auto &list = QStringView{ args }.split(' ');
|
||||||
auto argarray = new char*[list.count() + 1];
|
auto argarray = new char*[list.count() + 1];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -107,7 +107,6 @@ public:
|
|||||||
ba(LITERAL),
|
ba(LITERAL),
|
||||||
string(l1string),
|
string(l1string),
|
||||||
stdstring(LITERAL),
|
stdstring(LITERAL),
|
||||||
stringref(&string, 2, 10),
|
|
||||||
achar('c'),
|
achar('c'),
|
||||||
r2(QLatin1String(LITERAL LITERAL)),
|
r2(QLatin1String(LITERAL LITERAL)),
|
||||||
r3(QLatin1String(LITERAL LITERAL LITERAL)),
|
r3(QLatin1String(LITERAL LITERAL LITERAL)),
|
||||||
@ -191,18 +190,6 @@ private slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void separator_2c() { SEP("2 string refs"); }
|
|
||||||
|
|
||||||
void b_2_stringref() {
|
|
||||||
QBENCHMARK { r = stringref % stringref; }
|
|
||||||
COMPARE(r, QString(stringref.toString() + stringref.toString()));
|
|
||||||
}
|
|
||||||
void q_2_stringref() {
|
|
||||||
QBENCHMARK { r = stringref.toString() + stringref.toString(); }
|
|
||||||
COMPARE(r, QString(stringref % stringref));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void separator_2b() { SEP("3 strings"); }
|
void separator_2b() { SEP("3 strings"); }
|
||||||
|
|
||||||
void b_3_string() {
|
void b_3_string() {
|
||||||
@ -413,7 +400,6 @@ private:
|
|||||||
const QByteArray ba;
|
const QByteArray ba;
|
||||||
const QString string;
|
const QString string;
|
||||||
const std::string stdstring;
|
const std::string stdstring;
|
||||||
const QStringRef stringref;
|
|
||||||
const QLatin1Char achar;
|
const QLatin1Char achar;
|
||||||
const QString r2, r3, r4, r5;
|
const QString r2, r3, r4, r5;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user