Add QString::insert() overloads for QStringRef, const char*, QByteArray
The corresponding QString::append() overloads exists, and so should insert(). [ChangeLog][QtCore][QString] Added insert(int, QStringRef), insert(int, const char*) and insert(int, QByteArray). Change-Id: I1cf43fe8908319e2a57415945718b72e69ca0fb3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
parent
d543b1c3d4
commit
2a15c83c90
@ -1827,6 +1827,51 @@ QString &QString::operator=(QChar ch)
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString& QString::insert(int position, const QStringRef &str)
|
||||
\since 5.5
|
||||
\overload insert()
|
||||
|
||||
Inserts the string reference \a str at the given index \a position and
|
||||
returns a reference to this string.
|
||||
|
||||
If the given \a position is greater than size(), the array is
|
||||
first extended using resize().
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString& QString::insert(int position, const char *str)
|
||||
\since 5.5
|
||||
\overload insert()
|
||||
|
||||
Inserts the C string \a str at the given index \a position and
|
||||
returns a reference to this string.
|
||||
|
||||
If the given \a position is greater than size(), the array is
|
||||
first extended using resize().
|
||||
|
||||
This function is not available when QT_NO_CAST_FROM_ASCII is
|
||||
defined.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString& QString::insert(int position, const QByteArray &str)
|
||||
\since 5.5
|
||||
\overload insert()
|
||||
|
||||
Inserts the byte array \a str at the given index \a position and
|
||||
returns a reference to this string.
|
||||
|
||||
If the given \a position is greater than size(), the array is
|
||||
first extended using resize().
|
||||
|
||||
This function is not available when QT_NO_CAST_FROM_ASCII is
|
||||
defined.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString &QString::insert(int position, QLatin1String str)
|
||||
\overload insert()
|
||||
|
@ -420,6 +420,7 @@ public:
|
||||
QString &insert(int i, QChar c);
|
||||
QString &insert(int i, const QChar *uc, int len);
|
||||
inline QString &insert(int i, const QString &s) { return insert(i, s.constData(), s.length()); }
|
||||
inline QString &insert(int i, const QStringRef &s);
|
||||
QString &insert(int i, QLatin1String s);
|
||||
QString &append(QChar c);
|
||||
QString &append(const QChar *uc, int len);
|
||||
@ -668,6 +669,10 @@ public:
|
||||
{ return append(QString::fromUtf8(s)); }
|
||||
inline QT_ASCII_CAST_WARN QString &append(const QByteArray &s)
|
||||
{ return append(QString::fromUtf8(s)); }
|
||||
inline QT_ASCII_CAST_WARN QString &insert(int i, const char *s)
|
||||
{ return insert(i, QString::fromUtf8(s)); }
|
||||
inline QT_ASCII_CAST_WARN QString &insert(int i, const QByteArray &s)
|
||||
{ return insert(i, QString::fromUtf8(s)); }
|
||||
inline QT_ASCII_CAST_WARN QString &operator+=(const char *s)
|
||||
{ return append(QString::fromUtf8(s)); }
|
||||
inline QT_ASCII_CAST_WARN QString &operator+=(const QByteArray &s)
|
||||
@ -1576,6 +1581,9 @@ inline bool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
|
||||
inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
|
||||
{ return indexOf(s, 0, cs) != -1; }
|
||||
|
||||
inline QString &QString::insert(int i, const QStringRef &s)
|
||||
{ return insert(i, s.constData(), s.length()); }
|
||||
|
||||
namespace Qt {
|
||||
#if QT_DEPRECATED_SINCE(5, 0)
|
||||
QT_DEPRECATED inline QString escape(const QString &plain) {
|
||||
|
@ -432,14 +432,20 @@ private slots:
|
||||
|
||||
void insert_qstring() { insert_impl<QString>(); }
|
||||
void insert_qstring_data() { insert_data(true); }
|
||||
void insert_qstringref() { insert_impl<QStringRef>(); }
|
||||
void insert_qstringref_data() { insert_data(true); }
|
||||
void insert_qlatin1string() { insert_impl<QLatin1String, QString &(QString::*)(int, QLatin1String)>(); }
|
||||
void insert_qlatin1string_data() { insert_data(true); }
|
||||
void insert_qcharstar_int() { insert_impl<QPair<const QChar *, int>, QString &(QString::*)(int, const QChar*, int) >(); }
|
||||
void insert_qcharstar_int_data() { insert_data(true); }
|
||||
void insert_qchar() { insert_impl<Reversed<QChar>, QString &(QString::*)(int, QChar)>(); }
|
||||
void insert_qchar_data() { insert_data(true); }
|
||||
void insert_qbytearray() { insert_impl<QByteArray>(); }
|
||||
void insert_qbytearray_data() { insert_data(true); }
|
||||
void insert_char() { insert_impl<Reversed<char>, QString &(QString::*)(int, QChar)>(); }
|
||||
void insert_char_data() { insert_data(true); }
|
||||
void insert_charstar() { insert_impl<const char *, QString &(QString::*)(int, const char*) >(); }
|
||||
void insert_charstar_data() { insert_data(true); }
|
||||
void insert_special_cases();
|
||||
|
||||
void simplified_data();
|
||||
|
Loading…
Reference in New Issue
Block a user