Add a constructor that explicitly takes a size to QLatin1String
This is useful in a couple of situations where the size is known at runtime and one wants to avoid a call to strlen. Change-Id: Ic20587b0d365a4573d4636c5853c206b571b8d6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
parent
f8696140b0
commit
4f25e66f7a
@ -7164,6 +7164,19 @@ QString &QString::setRawData(const QChar *unicode, int size)
|
|||||||
\sa latin1()
|
\sa latin1()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \fn QLatin1String::QLatin1String(const char *str, int size)
|
||||||
|
|
||||||
|
Constructs a QLatin1String object that stores \a str with \a size.
|
||||||
|
Note that if \a str is 0, an empty string is created; this case
|
||||||
|
is handled by QString.
|
||||||
|
|
||||||
|
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
|
/*! \fn const char *QLatin1String::latin1() const
|
||||||
|
|
||||||
Returns the Latin-1 string stored in this object.
|
Returns the Latin-1 string stored in this object.
|
||||||
|
@ -646,6 +646,7 @@ class QLatin1String
|
|||||||
{
|
{
|
||||||
public:
|
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) : m_size(s ? int(strlen(s)) : 0), m_data(s) {}
|
||||||
|
Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int size) : m_size(size), m_data(s) {}
|
||||||
|
|
||||||
inline const char *latin1() const { return m_data; }
|
inline const char *latin1() const { return m_data; }
|
||||||
inline int size() const { return m_size; }
|
inline int size() const { return m_size; }
|
||||||
|
Loading…
Reference in New Issue
Block a user