QStringBuilder: use qsizetype for size() methods
Prompted by a ### Qt 6 comment on one of them. Task-number: QTBUG-85700 Change-Id: Id78a05a7bf77ba04207e0f5bc2a316984b13c9ae Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
3299476791
commit
691762e0e3
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
@ -130,7 +130,7 @@ public:
|
||||
typedef typename Concatenable::ConvertTo ConvertTo;
|
||||
operator ConvertTo() const { return convertTo<ConvertTo>(); }
|
||||
|
||||
int size() const { return Concatenable::size(*this); }
|
||||
qsizetype size() const { return Concatenable::size(*this); }
|
||||
|
||||
const A &a;
|
||||
const B &b;
|
||||
@ -176,7 +176,7 @@ template <> struct QConcatenable<char> : private QAbstractConcatenable
|
||||
typedef char type;
|
||||
typedef QByteArray ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const char) { return 1; }
|
||||
static qsizetype size(const char) { return 1; }
|
||||
#ifndef QT_NO_CAST_FROM_ASCII
|
||||
static inline QT_ASCII_CAST_WARN void appendTo(const char c, QChar *&out)
|
||||
{
|
||||
@ -192,7 +192,7 @@ template <> struct QConcatenable<char16_t> : private QAbstractConcatenable
|
||||
typedef char16_t type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static constexpr int size(char16_t) { return 1; }
|
||||
static constexpr qsizetype size(char16_t) { return 1; }
|
||||
static inline void appendTo(char16_t c, QChar *&out)
|
||||
{ *out++ = c; }
|
||||
};
|
||||
@ -202,7 +202,7 @@ template <> struct QConcatenable<QLatin1Char>
|
||||
typedef QLatin1Char type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const QLatin1Char) { return 1; }
|
||||
static qsizetype size(const QLatin1Char) { return 1; }
|
||||
static inline void appendTo(const QLatin1Char c, QChar *&out)
|
||||
{ *out++ = c; }
|
||||
static inline void appendTo(const QLatin1Char c, char *&out)
|
||||
@ -214,7 +214,7 @@ template <> struct QConcatenable<QChar> : private QAbstractConcatenable
|
||||
typedef QChar type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const QChar) { return 1; }
|
||||
static qsizetype size(const QChar) { return 1; }
|
||||
static inline void appendTo(const QChar c, QChar *&out)
|
||||
{ *out++ = c; }
|
||||
};
|
||||
@ -224,7 +224,7 @@ template <> struct QConcatenable<QChar::SpecialCharacter> : private QAbstractCon
|
||||
typedef QChar::SpecialCharacter type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const QChar::SpecialCharacter) { return 1; }
|
||||
static qsizetype size(const QChar::SpecialCharacter) { return 1; }
|
||||
static inline void appendTo(const QChar::SpecialCharacter c, QChar *&out)
|
||||
{ *out++ = c; }
|
||||
};
|
||||
@ -234,7 +234,7 @@ template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable
|
||||
typedef QLatin1String type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const QLatin1String a) { return int(a.size()); } // ### Qt 6: qsizetype
|
||||
static qsizetype size(const QLatin1String a) { return a.size(); }
|
||||
static inline void appendTo(const QLatin1String a, QChar *&out)
|
||||
{
|
||||
appendLatin1To(a.latin1(), a.size(), out);
|
||||
@ -254,7 +254,7 @@ template <> struct QConcatenable<QString> : private QAbstractConcatenable
|
||||
typedef QString type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(const QString &a) { return a.size(); }
|
||||
static qsizetype size(const QString &a) { return a.size(); }
|
||||
static inline void appendTo(const QString &a, QChar *&out)
|
||||
{
|
||||
const int n = a.size();
|
||||
@ -269,7 +269,7 @@ template <> struct QConcatenable<QStringView> : private QAbstractConcatenable
|
||||
typedef QStringView type;
|
||||
typedef QString ConvertTo;
|
||||
enum { ExactSize = true };
|
||||
static int size(QStringView a) { return a.length(); }
|
||||
static qsizetype size(QStringView a) { return a.size(); }
|
||||
static inline void appendTo(QStringView a, QChar *&out)
|
||||
{
|
||||
const auto n = a.size();
|
||||
@ -284,7 +284,7 @@ template <int N> struct QConcatenable<const char[N]> : private QAbstractConcaten
|
||||
typedef const char type[N];
|
||||
typedef QByteArray ConvertTo;
|
||||
enum { ExactSize = false };
|
||||
static int size(const char[N]) { return N - 1; }
|
||||
static qsizetype size(const char[N]) { return N - 1; }
|
||||
#ifndef QT_NO_CAST_FROM_ASCII
|
||||
static inline void QT_ASCII_CAST_WARN appendTo(const char a[N], QChar *&out)
|
||||
{
|
||||
@ -332,7 +332,7 @@ template <int N> struct QConcatenable<const char16_t[N]> : private QAbstractConc
|
||||
using type = const char16_t[N];
|
||||
using ConvertTo = QString;
|
||||
enum { ExactSize = true };
|
||||
static int size(const char16_t[N]) { return N - 1; }
|
||||
static qsizetype size(const char16_t[N]) { return N - 1; }
|
||||
static void appendTo(const char16_t a[N], QChar *&out)
|
||||
{
|
||||
memcpy(out, a, (N - 1) * sizeof(char16_t));
|
||||
@ -350,7 +350,7 @@ template <> struct QConcatenable<const char16_t *> : private QAbstractConcatenab
|
||||
using type = const char16_t *;
|
||||
using ConvertTo = QString;
|
||||
enum { ExactSize = true };
|
||||
static int size(const char16_t *a) { return QStringView(a).length(); }
|
||||
static qsizetype size(const char16_t *a) { return QStringView(a).size(); }
|
||||
static inline void QT_ASCII_CAST_WARN appendTo(const char16_t *a, QChar *&out)
|
||||
{
|
||||
if (!a)
|
||||
@ -370,7 +370,7 @@ template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
|
||||
typedef QByteArray type;
|
||||
typedef QByteArray ConvertTo;
|
||||
enum { ExactSize = false };
|
||||
static int size(const QByteArray &ba) { return ba.size(); }
|
||||
static qsizetype size(const QByteArray &ba) { return ba.size(); }
|
||||
#ifndef QT_NO_CAST_FROM_ASCII
|
||||
static inline QT_ASCII_CAST_WARN void appendTo(const QByteArray &ba, QChar *&out)
|
||||
{
|
||||
@ -393,7 +393,7 @@ struct QConcatenable< QStringBuilder<A, B> >
|
||||
typedef QStringBuilder<A, B> type;
|
||||
typedef typename QtStringBuilder::ConvertToTypeHelper<typename QConcatenable<A>::ConvertTo, typename QConcatenable<B>::ConvertTo>::ConvertTo ConvertTo;
|
||||
enum { ExactSize = QConcatenable<A>::ExactSize && QConcatenable<B>::ExactSize };
|
||||
static int size(const type &p)
|
||||
static qsizetype size(const type &p)
|
||||
{
|
||||
return QConcatenable<A>::size(p.a) + QConcatenable<B>::size(p.b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user