2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
#include "proitems.h"
|
|
|
|
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qset.h>
|
|
|
|
#include <qstringlist.h>
|
|
|
|
#include <qtextstream.h>
|
2017-05-18 12:49:04 +00:00
|
|
|
#include <private/qduplicatetracker_p.h>
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
// from qhash.cpp
|
2020-10-02 11:19:48 +00:00
|
|
|
size_t ProString::hash(const QChar *p, int n)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
2020-10-02 11:19:48 +00:00
|
|
|
size_t h = 0;
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
h = (h << 4) + (*p++).unicode();
|
|
|
|
h ^= (h & 0xf0000000) >> 23;
|
|
|
|
h &= 0x0fffffff;
|
|
|
|
}
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString() :
|
|
|
|
m_offset(0), m_length(0), m_file(0), m_hash(0x80000000)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const ProString &other) :
|
|
|
|
m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_file(other.m_file), m_hash(other.m_hash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const ProString &other, OmitPreHashing) :
|
|
|
|
m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_file(other.m_file), m_hash(0x80000000)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const QString &str, DoPreHashing) :
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_string(str), m_offset(0), m_length(str.size()), m_file(0)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
updatedHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const QString &str) :
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_string(str), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-30 21:29:21 +00:00
|
|
|
ProString::ProString(QStringView str) :
|
|
|
|
m_string(str.toString()), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000)
|
2017-08-10 18:53:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
ProString::ProString(const char *str, DoPreHashing) :
|
2020-10-02 11:19:48 +00:00
|
|
|
m_string(QString::fromLatin1(str)), m_offset(0), m_length(int(qstrlen(str))), m_file(0)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
updatedHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const char *str) :
|
2020-10-02 11:19:48 +00:00
|
|
|
m_string(QString::fromLatin1(str)), m_offset(0), m_length(int(qstrlen(str))), m_file(0), m_hash(0x80000000)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const QString &str, int offset, int length, DoPreHashing) :
|
|
|
|
m_string(str), m_offset(offset), m_length(length), m_file(0)
|
|
|
|
{
|
|
|
|
updatedHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const QString &str, int offset, int length, uint hash) :
|
|
|
|
m_string(str), m_offset(offset), m_length(length), m_file(0), m_hash(hash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString::ProString(const QString &str, int offset, int length) :
|
|
|
|
m_string(str), m_offset(offset), m_length(length), m_file(0), m_hash(0x80000000)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProString::setValue(const QString &str)
|
|
|
|
{
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_string = str, m_offset = 0, m_length = str.size(), m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 11:19:48 +00:00
|
|
|
size_t ProString::updatedHash() const
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
return (m_hash = hash(m_string.constData() + m_offset, m_length));
|
|
|
|
}
|
|
|
|
|
2020-01-31 11:11:54 +00:00
|
|
|
size_t qHash(const ProString &str)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
if (!(str.m_hash & 0x80000000))
|
|
|
|
return str.m_hash;
|
|
|
|
return str.updatedHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProKey::ProKey(const QString &str) :
|
|
|
|
ProString(str, DoHash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProKey::ProKey(const char *str) :
|
|
|
|
ProString(str, DoHash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProKey::ProKey(const QString &str, int off, int len) :
|
|
|
|
ProString(str, off, len, DoHash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProKey::ProKey(const QString &str, int off, int len, uint hash) :
|
|
|
|
ProString(str, off, len, hash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProKey::setValue(const QString &str)
|
|
|
|
{
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_string = str, m_offset = 0, m_length = str.size();
|
2012-09-05 16:29:19 +00:00
|
|
|
updatedHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ProString::toQString() const
|
|
|
|
{
|
|
|
|
return m_string.mid(m_offset, m_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString &ProString::toQString(QString &tmp) const
|
|
|
|
{
|
2019-11-16 22:25:26 +00:00
|
|
|
tmp = m_string.mid(m_offset, m_length);
|
|
|
|
return tmp;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProString &ProString::prepend(const ProString &other)
|
|
|
|
{
|
|
|
|
if (other.m_length) {
|
|
|
|
if (!m_length) {
|
|
|
|
*this = other;
|
|
|
|
} else {
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string = other.toQStringView() + toQStringView();
|
|
|
|
m_offset = 0;
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_length = m_string.size();
|
2012-09-05 16:29:19 +00:00
|
|
|
if (!m_file)
|
|
|
|
m_file = other.m_file;
|
2020-09-09 10:58:25 +00:00
|
|
|
m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString &ProString::append(const QLatin1String other)
|
|
|
|
{
|
2020-09-09 10:58:25 +00:00
|
|
|
if (other.size()) {
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (m_length != m_string.size()) {
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string = toQStringView() + other;
|
|
|
|
m_offset = 0;
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_length = m_string.size();
|
2020-09-09 10:58:25 +00:00
|
|
|
} else {
|
|
|
|
Q_ASSERT(m_offset == 0);
|
|
|
|
m_string.append(other);
|
|
|
|
m_length += other.size();
|
|
|
|
}
|
|
|
|
m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString &ProString::append(QChar other)
|
|
|
|
{
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (m_length != m_string.size()) {
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string = toQStringView() + other;
|
|
|
|
m_offset = 0;
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_length = m_string.size();
|
2020-09-09 10:58:25 +00:00
|
|
|
} else {
|
|
|
|
Q_ASSERT(m_offset == 0);
|
|
|
|
m_string.append(other);
|
|
|
|
++m_length;
|
|
|
|
}
|
|
|
|
m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If pending != 0, prefix with space if appending to non-empty non-pending
|
|
|
|
ProString &ProString::append(const ProString &other, bool *pending)
|
|
|
|
{
|
|
|
|
if (other.m_length) {
|
|
|
|
if (!m_length) {
|
|
|
|
*this = other;
|
|
|
|
} else {
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (m_length != m_string.size())
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string = toQString();
|
2012-09-05 16:29:19 +00:00
|
|
|
if (pending && !*pending) {
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string += QLatin1Char(' ') + other.toQStringView();
|
2012-09-05 16:29:19 +00:00
|
|
|
} else {
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string += other.toQStringView();
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_length = m_string.size();
|
2020-09-09 10:58:25 +00:00
|
|
|
m_offset = 0;
|
2012-09-05 16:29:19 +00:00
|
|
|
if (other.m_file)
|
|
|
|
m_file = other.m_file;
|
2020-09-09 10:58:25 +00:00
|
|
|
m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
if (pending)
|
|
|
|
*pending = true;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString &ProString::append(const ProStringList &other, bool *pending, bool skipEmpty1st)
|
|
|
|
{
|
|
|
|
if (const int sz = other.size()) {
|
|
|
|
int startIdx = 0;
|
|
|
|
if (pending && !*pending && skipEmpty1st && other.at(0).isEmpty()) {
|
|
|
|
if (sz == 1)
|
|
|
|
return *this;
|
|
|
|
startIdx = 1;
|
|
|
|
}
|
|
|
|
if (!m_length && sz == startIdx + 1) {
|
|
|
|
*this = other.at(startIdx);
|
|
|
|
} else {
|
|
|
|
bool putSpace = false;
|
|
|
|
if (pending && !*pending && m_length)
|
|
|
|
putSpace = true;
|
|
|
|
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string = toQString();
|
|
|
|
m_offset = 0;
|
2012-09-05 16:29:19 +00:00
|
|
|
for (int i = startIdx; i < sz; ++i) {
|
|
|
|
if (putSpace)
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string += QLatin1Char(' ');
|
2012-09-05 16:29:19 +00:00
|
|
|
else
|
|
|
|
putSpace = true;
|
|
|
|
const ProString &str = other.at(i);
|
2020-09-09 10:58:25 +00:00
|
|
|
m_string += str.toQStringView();
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
m_length = m_string.size();
|
2012-09-05 16:29:19 +00:00
|
|
|
if (other.last().m_file)
|
|
|
|
m_file = other.last().m_file;
|
2020-09-09 10:58:25 +00:00
|
|
|
m_hash = 0x80000000;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
if (pending)
|
|
|
|
*pending = true;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString operator+(const ProString &one, const ProString &two)
|
|
|
|
{
|
|
|
|
if (two.m_length) {
|
|
|
|
if (!one.m_length) {
|
|
|
|
return two.toQString();
|
|
|
|
} else {
|
|
|
|
QString neu(one.m_length + two.m_length, Qt::Uninitialized);
|
|
|
|
ushort *ptr = (ushort *)neu.constData();
|
|
|
|
memcpy(ptr, one.m_string.constData() + one.m_offset, one.m_length * 2);
|
|
|
|
memcpy(ptr + one.m_length, two.m_string.constData() + two.m_offset, two.m_length * 2);
|
|
|
|
return neu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return one.toQString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ProString ProString::mid(int off, int len) const
|
|
|
|
{
|
|
|
|
ProString ret(*this, NoHash);
|
|
|
|
if (off > m_length)
|
|
|
|
off = m_length;
|
|
|
|
ret.m_offset += off;
|
|
|
|
ret.m_length -= off;
|
|
|
|
if ((uint)ret.m_length > (uint)len) // Unsigned comparison to interpret < 0 as infinite
|
|
|
|
ret.m_length = len;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProString ProString::trimmed() const
|
|
|
|
{
|
|
|
|
ProString ret(*this, NoHash);
|
|
|
|
int cur = m_offset;
|
|
|
|
int end = cur + m_length;
|
|
|
|
const QChar *data = m_string.constData();
|
|
|
|
for (; cur < end; cur++)
|
|
|
|
if (!data[cur].isSpace()) {
|
|
|
|
// No underrun check - we know there is at least one non-whitespace
|
|
|
|
while (data[end - 1].isSpace())
|
|
|
|
end--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret.m_offset = cur;
|
|
|
|
ret.m_length = end - cur;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTextStream &operator<<(QTextStream &t, const ProString &str)
|
|
|
|
{
|
2020-05-30 21:29:21 +00:00
|
|
|
t << str.toQStringView();
|
2012-09-05 16:29:19 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2013-05-03 11:29:54 +00:00
|
|
|
static QString ProStringList_join(const ProStringList &this_, const QChar *sep, const int sepSize)
|
2012-09-05 16:29:19 +00:00
|
|
|
{
|
|
|
|
int totalLength = 0;
|
2012-09-19 15:50:42 +00:00
|
|
|
const int sz = this_.size();
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < sz; ++i)
|
2012-09-19 15:50:42 +00:00
|
|
|
totalLength += this_.at(i).size();
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
if (sz)
|
2012-09-19 15:50:42 +00:00
|
|
|
totalLength += sepSize * (sz - 1);
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
QString res(totalLength, Qt::Uninitialized);
|
|
|
|
QChar *ptr = (QChar *)res.constData();
|
|
|
|
for (int i = 0; i < sz; ++i) {
|
|
|
|
if (i) {
|
2012-09-19 15:50:42 +00:00
|
|
|
memcpy(ptr, sep, sepSize * sizeof(QChar));
|
|
|
|
ptr += sepSize;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
2012-09-19 15:50:42 +00:00
|
|
|
const ProString &str = this_.at(i);
|
|
|
|
memcpy(ptr, str.constData(), str.size() * sizeof(QChar));
|
|
|
|
ptr += str.size();
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-05-13 13:21:05 +00:00
|
|
|
QString ProStringList::join(const ProString &sep) const
|
|
|
|
{
|
|
|
|
return ProStringList_join(*this, sep.constData(), sep.size());
|
|
|
|
}
|
|
|
|
|
2012-09-19 15:50:42 +00:00
|
|
|
QString ProStringList::join(const QString &sep) const
|
|
|
|
{
|
|
|
|
return ProStringList_join(*this, sep.constData(), sep.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ProStringList::join(QChar sep) const
|
|
|
|
{
|
|
|
|
return ProStringList_join(*this, &sep, 1);
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
void ProStringList::removeAll(const ProString &str)
|
|
|
|
{
|
|
|
|
for (int i = size(); --i >= 0; )
|
|
|
|
if (at(i) == str)
|
|
|
|
remove(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProStringList::removeAll(const char *str)
|
|
|
|
{
|
|
|
|
for (int i = size(); --i >= 0; )
|
|
|
|
if (at(i) == str)
|
|
|
|
remove(i);
|
|
|
|
}
|
|
|
|
|
2015-01-30 18:18:54 +00:00
|
|
|
void ProStringList::removeEach(const ProStringList &value)
|
|
|
|
{
|
2016-12-16 12:34:02 +00:00
|
|
|
for (const ProString &str : value) {
|
|
|
|
if (isEmpty())
|
|
|
|
break;
|
2015-01-30 18:18:54 +00:00
|
|
|
if (!str.isEmpty())
|
|
|
|
removeAll(str);
|
2016-12-16 12:34:02 +00:00
|
|
|
}
|
2015-01-30 18:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProStringList::removeEmpty()
|
|
|
|
{
|
|
|
|
for (int i = size(); --i >= 0;)
|
|
|
|
if (at(i).isEmpty())
|
|
|
|
remove(i);
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
void ProStringList::removeDuplicates()
|
|
|
|
{
|
2021-07-12 09:15:44 +00:00
|
|
|
QDuplicateTracker<ProString> seen(size());
|
2017-05-18 12:49:04 +00:00
|
|
|
removeIf([&](const ProString &s) { return seen.hasSeen(s); });
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 18:18:54 +00:00
|
|
|
void ProStringList::insertUnique(const ProStringList &value)
|
|
|
|
{
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &str : value)
|
2015-01-30 18:18:54 +00:00
|
|
|
if (!str.isEmpty() && !contains(str))
|
|
|
|
append(str);
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
ProStringList::ProStringList(const QStringList &list)
|
|
|
|
{
|
|
|
|
reserve(list.size());
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const QString &str : list)
|
2012-09-05 16:29:19 +00:00
|
|
|
*this << ProString(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList ProStringList::toQStringList() const
|
|
|
|
{
|
|
|
|
QStringList ret;
|
|
|
|
ret.reserve(size());
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const auto &e : *this)
|
|
|
|
ret.append(e.toQString());
|
2012-09-05 16:29:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ProStringList::contains(const ProString &str, Qt::CaseSensitivity cs) const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < size(); i++)
|
|
|
|
if (!at(i).compare(str, cs))
|
|
|
|
return true;
|
|
|
|
return false;
|
2016-05-13 13:26:42 +00:00
|
|
|
}
|
|
|
|
|
2020-05-30 21:29:21 +00:00
|
|
|
bool ProStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
|
2016-05-13 13:26:42 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < size(); i++)
|
2020-05-30 21:29:21 +00:00
|
|
|
if (!at(i).toQStringView().compare(str, cs))
|
2016-05-13 13:26:42 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ProStringList::contains(const char *str, Qt::CaseSensitivity cs) const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < size(); i++)
|
|
|
|
if (!at(i).compare(str, cs))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-14 16:30:29 +00:00
|
|
|
ProFile::ProFile(int id, const QString &fileName)
|
2012-09-05 16:29:19 +00:00
|
|
|
: m_refCount(1),
|
|
|
|
m_fileName(fileName),
|
2017-08-14 16:30:29 +00:00
|
|
|
m_id(id),
|
2012-09-05 16:29:19 +00:00
|
|
|
m_ok(true),
|
|
|
|
m_hostBuild(false)
|
|
|
|
{
|
|
|
|
if (!fileName.startsWith(QLatin1Char('(')))
|
|
|
|
m_directoryName = QFileInfo( // qmake sickness: canonicalize only the directory!
|
|
|
|
fileName.left(fileName.lastIndexOf(QLatin1Char('/')))).canonicalFilePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProFile::~ProFile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-04 20:38:31 +00:00
|
|
|
ProString ProFile::getStr(const ushort *&tPtr)
|
|
|
|
{
|
|
|
|
uint len = *tPtr++;
|
|
|
|
ProString ret(items(), tPtr - tokPtr(), len);
|
2017-08-14 16:30:29 +00:00
|
|
|
ret.setSource(m_id);
|
2015-03-04 20:38:31 +00:00
|
|
|
tPtr += len;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProKey ProFile::getHashStr(const ushort *&tPtr)
|
|
|
|
{
|
|
|
|
uint hash = *tPtr++;
|
|
|
|
hash |= (uint)*tPtr++ << 16;
|
|
|
|
uint len = *tPtr++;
|
|
|
|
ProKey ret(items(), tPtr - tokPtr(), len, hash);
|
|
|
|
tPtr += len;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-06-24 15:36:41 +00:00
|
|
|
QDebug operator<<(QDebug debug, const ProString &str)
|
|
|
|
{
|
|
|
|
return debug << str.toQString();
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
QT_END_NAMESPACE
|