add a bunch of ProString::append() overloads

Change-Id: I9f1f62d8ba57a1bec2c55fe32709b2f6db0f7882
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Oswald Buddenhagen
2012-08-21 19:40:14 +02:00
parent 9f8b9eaf16
commit 422485c892
2 changed files with 32 additions and 1 deletions

View File

@@ -194,6 +194,29 @@ ProString &ProString::prepend(const ProString &other)
return *this;
}
ProString &ProString::append(const QLatin1String other)
{
const char *latin1 = other.latin1();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
int size = other.size();
#else
int size = strlen(latin1);
#endif
if (size) {
QChar *ptr = prepareExtend(size, 0, m_length);
for (int i = 0; i < size; i++)
*ptr++ = QLatin1Char(latin1[i]);
}
return *this;
}
ProString &ProString::append(QChar other)
{
QChar *ptr = prepareExtend(1, 0, m_length);
*ptr = other;
return *this;
}
// If pending != 0, prefix with space if appending to non-empty non-pending
ProString &ProString::append(const ProString &other, bool *pending)
{

View File

@@ -79,9 +79,17 @@ public:
const ProFile *sourceFile() const { return m_file; }
ProString &prepend(const ProString &other);
ProString &operator+=(const ProString &other);
ProString &append(const ProString &other, bool *pending = 0);
ProString &append(const QString &other) { return append(ProString(other)); }
ProString &append(const QLatin1String other);
ProString &append(const char *other) { return append(QLatin1String(other)); }
ProString &append(QChar other);
ProString &append(const ProStringList &other, bool *pending = 0, bool skipEmpty1st = false);
ProString &operator+=(const ProString &other) { return append(other); }
ProString &operator+=(const QString &other) { return append(other); }
ProString &operator+=(const QLatin1String other) { return append(other); }
ProString &operator+=(const char *other) { return append(other); }
ProString &operator+=(QChar other) { return append(other); }
void chop(int n) { Q_ASSERT(n <= m_length); m_length -= n; }
void chopFront(int n) { Q_ASSERT(n <= m_length); m_offset += n; m_length -= n; }