qmake: add ProStringList::join(QChar)
Same reasoning as for 68e04c3ac1
applies.
Adding the overload was easier than to teach a Perl script to distinguish
between QStringList and ProStringList instances...
Change-Id: I6de6ecf21fdad135ac213b5c794927a9bc120a92
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
1f576cb6ab
commit
cbf447069c
@ -345,30 +345,41 @@ QTextStream &operator<<(QTextStream &t, const ProString &str)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProStringList::join(const QString &sep) const
|
static QString ProStringList_join(const ProStringList &this_, const QChar *sep, const size_t sepSize)
|
||||||
{
|
{
|
||||||
int totalLength = 0;
|
int totalLength = 0;
|
||||||
const int sz = size();
|
const int sz = this_.size();
|
||||||
|
|
||||||
for (int i = 0; i < sz; ++i)
|
for (int i = 0; i < sz; ++i)
|
||||||
totalLength += at(i).size();
|
totalLength += this_.at(i).size();
|
||||||
|
|
||||||
if (sz)
|
if (sz)
|
||||||
totalLength += sep.size() * (sz - 1);
|
totalLength += sepSize * (sz - 1);
|
||||||
|
|
||||||
QString res(totalLength, Qt::Uninitialized);
|
QString res(totalLength, Qt::Uninitialized);
|
||||||
QChar *ptr = (QChar *)res.constData();
|
QChar *ptr = (QChar *)res.constData();
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
if (i) {
|
if (i) {
|
||||||
memcpy(ptr, sep.constData(), sep.size() * 2);
|
memcpy(ptr, sep, sepSize * sizeof(QChar));
|
||||||
ptr += sep.size();
|
ptr += sepSize;
|
||||||
}
|
}
|
||||||
memcpy(ptr, at(i).constData(), at(i).size() * 2);
|
const ProString &str = this_.at(i);
|
||||||
ptr += at(i).size();
|
memcpy(ptr, str.constData(), str.size() * sizeof(QChar));
|
||||||
|
ptr += str.size();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void ProStringList::removeAll(const ProString &str)
|
void ProStringList::removeAll(const ProString &str)
|
||||||
{
|
{
|
||||||
for (int i = size(); --i >= 0; )
|
for (int i = size(); --i >= 0; )
|
||||||
|
@ -245,6 +245,7 @@ public:
|
|||||||
int length() const { return size(); }
|
int length() const { return size(); }
|
||||||
|
|
||||||
QString join(const QString &sep) const;
|
QString join(const QString &sep) const;
|
||||||
|
QString join(QChar sep) const;
|
||||||
|
|
||||||
void removeAll(const ProString &str);
|
void removeAll(const ProString &str);
|
||||||
void removeAll(const char *str);
|
void removeAll(const char *str);
|
||||||
|
Loading…
Reference in New Issue
Block a user