ProString &ProString::append(const QLatin1String other) { const char *latin1 = other.latin1(); int size = other.size(); if (size) { QChar *ptr = prepareExtend(size, 0, m_length); for (int i = 0; i < size; i++) *ptr++ = QLatin1Char(latin1[i]); } 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 { QChar *ptr; if (pending && !*pending) { ptr = prepareExtend(1 + other.m_length, 0, m_length); *ptr++ = 32; } else { ptr = prepareExtend(other.m_length, 0, m_length); } memcpy(ptr, other.m_string.constData() + other.m_offset, other.m_length * 2); if (other.m_file) m_file = other.m_file; } if (pending) *pending = true; } return *this; }
ProString &ProString::prepend(const ProString &other) { if (other.m_length) { if (!m_length) { *this = other; } else { QChar *ptr = prepareExtend(other.m_length, other.m_length, 0); memcpy(ptr, other.constData(), other.m_length * 2); if (!m_file) m_file = other.m_file; } } 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(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 { int totalLength = sz - startIdx; for (int i = startIdx; i < sz; ++i) totalLength += other.at(i).size(); bool putSpace = false; if (pending && !*pending && m_length) putSpace = true; else totalLength--; QChar *ptr = prepareExtend(totalLength, 0, m_length); for (int i = startIdx; i < sz; ++i) { if (putSpace) *ptr++ = 32; else putSpace = true; const ProString &str = other.at(i); memcpy(ptr, str.m_string.constData() + str.m_offset, str.m_length * 2); ptr += str.m_length; } if (other.last().m_file) m_file = other.last().m_file; } if (pending) *pending = true; } return *this; }
ProString &ProString::append(QChar other) { QChar *ptr = prepareExtend(1, 0, m_length); *ptr = other; return *this; }