summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2010-02-22 13:14:22 (GMT)
committerZeno Albisser <zeno.albisser@nokia.com>2010-02-23 08:17:21 (GMT)
commitd1592b1d4f6f0ea0d180e6848af42b3692e7490a (patch)
treefd20dc2031cc76dd59cf64a20f0390f5d362fc6a /src/corelib/tools/qbytearray.cpp
parentfcdecd732d2fd6a863e903239f71c8f050c88dd0 (diff)
downloadQt-d1592b1d4f6f0ea0d180e6848af42b3692e7490a.zip
Qt-d1592b1d4f6f0ea0d180e6848af42b3692e7490a.tar.gz
Qt-d1592b1d4f6f0ea0d180e6848af42b3692e7490a.tar.bz2
Added function overload for QByteArray &QByteArray::replace()
This overloaded function can be used to replace a specific portion of a QByteArray with an arbitary amount of characters from a char[]. Reviewed-by: Markus Goetz
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index a27e488..3324796 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1804,7 +1804,20 @@ QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after)
*/
QByteArray &QByteArray::replace(int pos, int len, const char *after)
{
- int alen = qstrlen(after);
+ return replace(pos,len,after,qstrlen(after));
+}
+
+/*! \fn QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
+
+ \overload
+
+ Replaces \a len bytes from index position \a pos with \a alen bytes
+ from the string \a after. \a after is allowed to have '\0' characters.
+
+ \since 4.7
+*/
+QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
+{
if (len == alen && (pos + len <= d->size)) {
detach();
memcpy(d->data + pos, after, len*sizeof(char));