diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-03-14 15:36:50 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-14 21:46:55 +0100 |
commit | 2c944d6b9dd7d750835cca491aac60825cd7d1ed (patch) | |
tree | 9abf4665ae39d7f3945341bd69fc7824d824f754 | |
parent | ded80cfc8a3f258a85954b4fd19063f9988f3744 (diff) |
Add QByteArray overload for the QLatin1String ctor.
This increases source compatibility when QT_NO_CAST_FROM_BYTEARRAY
is used.
Change-Id: Ie1a1cfa8acac2fa91aa8f217d91e22289be8b38f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/tools/qstring.cpp | 11 | ||||
-rw-r--r-- | src/corelib/tools/qstring.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 79e3577727..584502f713 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -7164,6 +7164,17 @@ QString &QString::setRawData(const QChar *unicode, int size) \sa latin1() */ +/*! \fn QLatin1String::QLatin1String(const QByteArray &str) + + Constructs a QLatin1String object that stores \a str. + + The string data is \e not copied. The caller must be able to + guarantee that \a str will not be deleted or modified as long as + the QLatin1String object exists. + + \sa latin1() +*/ + /*! \fn const char *QLatin1String::latin1() const Returns the Latin-1 string stored in this object. diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 26959d81f3..b71484f4cb 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -647,6 +647,7 @@ class QLatin1String public: Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) : m_size(s ? int(strlen(s)) : 0), m_data(s) {} Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) : m_size(sz), m_data(s) {} + Q_DECL_CONSTEXPR inline explicit QLatin1String(const QByteArray &s) : m_size(strlen(s.constData())), m_data(s.constData()) {} inline const char *latin1() const { return m_data; } inline int size() const { return m_size; } |