diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-06-19 11:01:33 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-06-25 16:51:53 +0200 |
commit | a1fc11ca655850a47701f3715f1408c336ddb6c7 (patch) | |
tree | 39f897d1674a11368ef98a840edea178be48ee4e /src/corelib/tools/qbytearray.cpp | |
parent | 273ed8e0fa527f4c4382d45eaced54314318173f (diff) |
Introduce std::string conversion to QByteArray
Add conversion methods similar to those in QString to QByteArray. This
is often more useful than the QString version since std::string like
QByteArray are byte arrays.
[ChangeLog][QtCore][QByteArray] Added convenience methods to convert
directly to and from std::string.
Change-Id: I92c29d4bb1d9e06a667dd9cdd936970e2d272006
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6fed3ae5c9..7ca47961c0 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -4189,6 +4189,27 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent return tmp; } +/*! \fn QByteArray QByteArray::fromStdString(const std::string &str) + \since 5.4 + + Returns a copy of the \a str string as a QByteArray. + + \sa toStdString(), QString::fromStdString() +*/ + +/*! + \fn std::string QByteArray::toStdString() const + \since 5.4 + + Returns a std::string object with the data contained in this + QByteArray. + + This operator is mostly useful to pass a QByteArray to a function + that accepts a std::string object. + + \sa fromStdString(), QString::toStdString() +*/ + /*! \fn QByteArray QByteArray::fromCFData(CFDataRef data) \since 5.3 |