10#if defined(QT_NO_CAST_FROM_ASCII) && defined(QT_RESTRICTED_CAST_FROM_ASCII)
11#error QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII must not be defined at the same time
14#include <QtCore/qchar.h>
15#include <QtCore/qcompare.h>
16#include <QtCore/qbytearray.h>
17#include <QtCore/qbytearrayview.h>
18#include <QtCore/qarraydata.h>
19#include <QtCore/qlatin1stringview.h>
20#include <QtCore/qnamespace.h>
21#include <QtCore/qstringliteral.h>
22#include <QtCore/qstringalgorithms.h>
23#include <QtCore/qanystringview.h>
24#include <QtCore/qstringtokenizer.h>
28#include <QtCore/q20memory.h>
34#error qstring.h must be included before any header file that defines truncate
37#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
53template <
typename Char>
55 std::is_same<Char, char32_t>;
56template <
typename Char>
58 = IsCompatibleChar32TypeHelper<q20::remove_cvref_t<Char>>;
103template <
typename Visitor>
107 return std::forward<Visitor>(
v)(asStringView());
109 return std::forward<Visitor>(
v)(asLatin1StringView());
111 return std::forward<Visitor>(
v)(asUtf8StringView());
120 return visit([] (
auto that) {
return QAnyStringView::toQChar(that.front()); });
124 return visit([] (
auto that) {
return QAnyStringView::toQChar(that.back()); });
130 typedef QTypedArrayData<char16_t>
Data;
132 friend class ::tst_QString;
134 template <
typename Iterator>
135 static constexpr bool is_contiguous_iterator_v =
140 std::is_pointer_v<Iterator>;
142 template <
typename Char>
143 using is_compatible_char_helper = std::disjunction<
147 std::is_same<Char, QLatin1Char>
150 template <
typename Iterator>
151 static constexpr bool is_compatible_iterator_v = std::conjunction_v<
153 typename std::iterator_traits<Iterator>::iterator_category,
154 std::input_iterator_tag
156 is_compatible_char_helper<typename std::iterator_traits<Iterator>::value_type>
159 template <
typename Iterator>
160 using if_compatible_iterator = std::enable_if_t<is_compatible_iterator_v<Iterator>,
bool>;
171#if defined(__cpp_char8_t) || defined(Q_QDOC)
184 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(
QString)
187#if QT_DEPRECATED_SINCE(6, 4)
192 inline bool isEmpty() const noexcept {
return d.size == 0; }
214 inline void squeeze();
216 inline const QChar *unicode()
const;
219 inline const QChar *constData()
const;
221 inline void detach();
222 inline bool isDetached()
const;
231 [[nodiscard]]
inline QChar &front();
233 [[nodiscard]]
inline QChar &back();
236 QChar fillChar = u
' ')
const;
238 QChar fillChar = u
' ')
const;
239 [[nodiscard]]
inline QString arg(
long a,
int fieldwidth=0,
int base=10,
240 QChar fillChar = u
' ')
const;
242 QChar fillChar = u
' ')
const;
243 [[nodiscard]]
inline QString arg(
int a,
int fieldWidth = 0,
int base = 10,
244 QChar fillChar = u
' ')
const;
246 QChar fillChar = u
' ')
const;
247 [[nodiscard]]
inline QString arg(
short a,
int fieldWidth = 0,
int base = 10,
248 QChar fillChar = u
' ')
const;
250 QChar fillChar = u
' ')
const;
252 QChar fillChar = u
' ')
const;
253 [[nodiscard]]
QString arg(
char a,
int fieldWidth = 0,
254 QChar fillChar = u
' ')
const;
256 QChar fillChar = u
' ')
const;
258 QChar fillChar = u
' ')
const;
260 QChar fillChar = u
' ')
const;
262 QChar fillChar = u
' ')
const;
264 template <
typename T>
265 using is_convertible_to_view_or_qstring = std::disjunction<
266 std::is_convertible<T, QString>,
267 std::is_convertible<T, QStringView>,
268 std::is_convertible<T, QLatin1StringView>
271 template <
typename...Args>
276 typename std::enable_if<
277 sizeof...(Args) >= 2 && std::is_same<
290 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 7)
320#if QT_CONFIG(regularexpression)
327 template <
typename T = QRegularExpressionMatch, std::enable_if_t<std::is_same_v<T, QRegularExpressionMatch>,
bool> = false>
338 SectionDefault = 0x00,
339 SectionSkipEmpty = 0x01,
340 SectionIncludeLeadingSep = 0x02,
341 SectionIncludeTrailingSep = 0x04,
342 SectionCaseInsensitiveSeps = 0x08
348#if QT_CONFIG(regularexpression)
352#if QT_CORE_REMOVED_SINCE(6, 7)
365 if (
size_t(
n) >=
size_t(
size()))
371 if (
size_t(
n) >=
size_t(
size()))
372 return std::move(*
this);
373 return std::move(*this).first(
n);
377 if (
size_t(
n) >=
size_t(
size()))
383 if (
size_t(
n) >=
size_t(
size()))
384 return std::move(*
this);
385 return std::move(*this).last(
n);
391 { verify(0,
n);
return sliced(0,
n); }
393 { verify(0,
n);
return sliced(
size() -
n,
n); }
399 { verify(0,
n);
return sliced(0,
size() -
n); }
405 return std::move(*
this);
408 { verify(0,
n);
return sliced_helper(*
this,
size() -
n,
n); }
410 { verify(
pos, 0);
return sliced_helper(*
this,
pos,
size() -
pos); }
412 { verify(
pos,
n);
return sliced_helper(*
this,
pos,
n); }
414 { verify(0,
n);
return std::move(*this).first(
size() -
n); }
428 bool isUpper()
const;
429 bool isLower()
const;
436 {
return toLower_helper(*
this); }
438 {
return toLower_helper(*
this); }
440 {
return toUpper_helper(*
this); }
442 {
return toUpper_helper(*
this); }
444 {
return toCaseFolded_helper(*
this); }
446 {
return toCaseFolded_helper(*
this); }
448 {
return trimmed_helper(*
this); }
450 {
return trimmed_helper(*
this); }
452 {
return simplified_helper(*
this); }
454 {
return simplified_helper(*
this); }
456 [[nodiscard]]
QString toLower()
const;
457 [[nodiscard]]
QString toUpper()
const;
458 [[nodiscard]]
QString toCaseFolded()
const;
459 [[nodiscard]]
QString trimmed()
const;
460 [[nodiscard]]
QString simplified()
const;
462 [[nodiscard]]
QString toHtmlEscaped()
const;
491 template <
typename InputIterator, if_compatible_iterator<InputIterator> = true>
494 using V =
typename std::iterator_traits<InputIterator>::value_type;
495 constexpr bool IsL1C = std::is_same_v<std::remove_cv_t<V>,
QLatin1Char>;
496 constexpr bool IsFwdIt = std::is_convertible_v<
497 typename std::iterator_traits<InputIterator>::iterator_category,
498 std::forward_iterator_tag
501 if constexpr (is_contiguous_iterator_v<InputIterator>) {
506 else if constexpr (
sizeof(V) == 4)
507 return assign_helper(
p,
len);
510 }
else if constexpr (
sizeof(V) == 4) {
512 if constexpr (IsFwdIt) {
513 const qsizetype requiredCapacity = 2 * std::distance(
first, last);
516 while (
first != last) {
522 assign_helper_char8(
first, last);
523 d.data()[
d.size] = u
'\0';
526 d.assign(
first, last, [](
QChar ch) ->
char16_t {
return ch.unicode(); });
527 d.data()[
d.size] = u
'\0';
539#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
540 template <qsizetype N>
542 template <qsizetype N>
544 template <qsizetype N>
546 template <qsizetype N>
560 template <
typename Predicate>
563 removeIf_helper(pred);
579#if QT_CONFIG(regularexpression)
582 {
return replace(re,
QString()); }
592#ifndef QT_NO_REGULAREXPRESSION
598 template <
typename Needle,
typename...Flags>
604 template <
typename Needle,
typename...Flags>
608 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle),
flags...); }
610 template <
typename Needle,
typename...Flags>
612 noexcept(
noexcept(
qTokenize(std::declval<QString>(), std::forward<Needle>(needle),
flags...)))
613 ->
decltype(
qTokenize(std::move(*
this), std::forward<Needle>(needle),
flags...))
614 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle),
flags...); }
623 [[nodiscard]]
QString normalized(NormalizationForm
mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned)
const;
627 const ushort *utf16()
const;
631 {
return toLatin1_helper(*
this); }
633 {
return toLatin1_helper_inplace(*
this); }
635 {
return toUtf8_helper(*
this); }
637 {
return toUtf8_helper(*
this); }
639 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(),
size()); }
641 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(),
size()); }
647 [[nodiscard]] QList<uint> toUcs4()
const;
664#if defined(__cpp_char8_t) || defined(Q_QDOC)
666 static inline QString fromUtf8(
const char8_t *
str)
667 {
return fromUtf8(
reinterpret_cast<const char *
>(
str)); }
683#if QT_DEPRECATED_SINCE(6, 0)
689 {
return fromUcs4(
reinterpret_cast<const char32_t *
>(
str),
size); }
707 {
return s1.compare(
s2, cs); }
711 {
return s1.compare(
s2, cs); }
714 {
return -
s2.compare(
s1, cs); }
716 {
return s1.compare(
s2, cs); }
718 {
return -
s2.compare(
s1, cs); }
720 int localeAwareCompare(
const QString&
s)
const;
723 {
return s1.localeAwareCompare(
s2); }
728 {
return toIntegral_helper<short>(*
this,
ok,
base); }
730 {
return toIntegral_helper<ushort>(*
this,
ok,
base); }
732 {
return toIntegral_helper<int>(*
this,
ok,
base); }
734 {
return toIntegral_helper<uint>(*
this,
ok,
base); }
736 {
return toIntegral_helper<long>(*
this,
ok,
base); }
738 {
return toIntegral_helper<ulong>(*
this,
ok,
base); }
739 QT_CORE_INLINE_SINCE(6, 5)
741 QT_CORE_INLINE_SINCE(6, 5)
743 float toFloat(
bool *
ok=
nullptr) const;
802 {
return s1.isEmpty(); }
815 {
return lhs.size() == 1 && rhs == lhs.front(); }
818 const int res = compare_helper(lhs.data(), lhs.size(), &rhs, 1);
824#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
825 template <qsizetype N>
829 template <qsizetype N>
831 template <qsizetype N>
832 inline QString &operator=(
const char (&
ch)[N])
834 template <qsizetype N>
835 QString &operator=(
char (&)[N]) =
delete;
837#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
878#if QT_CORE_REMOVED_SINCE(6, 8)
895 return QString::compare_helper(lhs.constData(), lhs.size(),
896 rhs.constData(), rhs.size()) == 0;
901 const int res = QString::compare_helper(lhs.constData(), lhs.size(),
902 rhs.constData(), rhs.size());
962 iterator
erase(const_iterator
first, const_iterator last);
967 return Data::max_size() - 1;
970 static inline QString fromStdString(
const std::string &
s);
971 inline std::string toStdString()
const;
972 static inline QString fromStdWString(
const std::wstring &
s);
973 inline std::wstring toStdWString()
const;
975 static inline QString fromStdU16String(
const std::u16string &
s);
976 inline std::u16string toStdU16String()
const;
977 static inline QString fromStdU32String(
const std::u32string &
s);
978 inline std::u32string toStdU32String()
const;
980 Q_IMPLICIT inline operator std::u16string_view() const noexcept;
982#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
983 static QString fromCFString(CFStringRef
string);
985 static
QString fromNSString(const NSString *
string);
989#if defined(Q_OS_WASM) || defined(Q_QDOC)
990 static QString fromEcmaString(emscripten::val jsString);
991 emscripten::val toEcmaString()
const;
994 inline bool isNull()
const {
return d->isNull(); }
996 bool isRightToLeft()
const;
1004#if defined(QT_NO_CAST_FROM_ASCII)
1014 static const char16_t _empty;
1021 template <
typename InputIterator>
1022 void assign_helper_char8(InputIterator
first, InputIterator last);
1029 static int localeAwareCompare_helper(
const QChar *data1,
qsizetype length1,
1046#if QT_CORE_REMOVED_SINCE(6, 6)
1052 template <
typename Predicate>
1053 qsizetype removeIf_helper(Predicate pred)
1057 d.data()[
d.size] = u
'\0';
1067 template <
typename T>
static
1071 using Int32 =
typename std::conditional<std::is_unsigned<T>::value,
uint,
int>
::type;
1125{
return QString::toIntegral_helper<qint64>(*
this,
ok,
base); }
1127{
return QString::toIntegral_helper<quint64>(*
this,
ok,
base); }
1129{
return QString::toIntegral_helper<long>(*
this,
ok,
base); }
1131{
return QString::toIntegral_helper<ulong>(*
this,
ok,
base); }
1133{
return QString::toIntegral_helper<int>(*
this,
ok,
base); }
1135{
return QString::toIntegral_helper<uint>(*
this,
ok,
base); }
1137{
return QString::toIntegral_helper<short>(*
this,
ok,
base); }
1139{
return QString::toIntegral_helper<ushort>(*
this,
ok,
base); }
1145template <
bool UseChar8T>
1151template <
bool UseChar8T>
1157template <
bool UseChar8T>
1163template <
bool UseChar8T>
1173template <
bool UseChar8T>
1179template<
bool UseChar8T>
1186template<
bool UseChar8T>
1191 QBasicUtf8StringView<UseChar8T>(
other.data(),
other.size()),
1195template <
bool UseChar8T>
1201template <
bool UseChar8T>
1227{ verify(
i, 1);
return QChar(
d.data()[
i]); }
1229{ verify(
i, 1);
return QChar(
d.data()[
i]); }
1234#if QT5_NULL_STRINGS == 1
1235 return reinterpret_cast<const QChar *
>(
d.data() ?
d.data() : &_empty);
1237 return reinterpret_cast<const QChar *
>(
d.data());
1244 return reinterpret_cast<QChar *
>(
d.data());
1251{
return !
d->isShared(); }
1253{
if (!isNull()) *
this =
QString(); }
1270{
return setNum(
double(
n),
f,prec); }
1285{
return section(
QString(asep), astart, aend, aflags); }
1298 if (
sizeof(
wchar_t) ==
sizeof(
QChar)) {
1303 return QString::toUcs4_helper(utf16(),
size(),
reinterpret_cast<char32_t *
>(
array));
1311 if constexpr (
sizeof(wchar_t) ==
sizeof(
QChar)) {
1314#ifdef QT_BOOTSTRAPPED
1315 Q_UNREACHABLE_RETURN(
QString());
1317 return fromUcs4(
reinterpret_cast<const char32_t *
>(
string),
size);
1327 if (
d->needsDetach() || asize >=
capacity() -
d.freeSpaceAtBegin())
1329 if (
d->constAllocatedCapacity())
1330 d->setFlag(Data::CapacityReserved);
1339 if (
d->constAllocatedCapacity())
1340 d->clearFlag(Data::CapacityReserved);
1344{
return setUnicode(
reinterpret_cast<const QChar *
>(autf16), asize); }
1346{ verify(
i, 1);
return data()[
i]; }
1350{ detach();
return reinterpret_cast<QChar*
>(
d.data()); }
1352{
return reinterpret_cast<const QChar*
>(
d.data()); }
1354{
return reinterpret_cast<const QChar*
>(
d.data()); }
1356{
return reinterpret_cast<const QChar*
>(
d.data()); }
1358{ detach();
return reinterpret_cast<QChar*
>(
d.data() +
d.size); }
1360{
return reinterpret_cast<const QChar*
>(
d.data() +
d.size); }
1362{
return reinterpret_cast<const QChar*
>(
d.data() +
d.size); }
1364{
return reinterpret_cast<const QChar*
>(
d.data() +
d.size); }
1374#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
1375#if QT_CORE_REMOVED_SINCE(6, 8)
1376bool QString::operator==(
const char *
s)
const
1377{
return QString::compare_helper(constData(),
size(),
s, -1) == 0; }
1378bool QString::operator!=(
const char *
s)
const
1379{
return QString::compare_helper(constData(),
size(),
s, -1) != 0; }
1380bool QString::operator<(
const char *
s)
const
1381{
return QString::compare_helper(constData(),
size(),
s, -1) < 0; }
1382bool QString::operator>(
const char *
s)
const
1383{
return QString::compare_helper(constData(),
size(),
s, -1) > 0; }
1384bool QString::operator<=(
const char *
s)
const
1385{
return QString::compare_helper(constData(),
size(),
s, -1) <= 0; }
1386bool QString::operator>=(
const char *
s)
const
1387{
return QString::compare_helper(constData(),
size(),
s, -1) >= 0; }
1390{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) == 0; }
1392{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) != 0; }
1394{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) < 0; }
1396{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) > 0; }
1398{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) <= 0; }
1400{
return QString::compare_helper(constData(),
size(),
s.constData(),
s.size()) >= 0; }
1402bool QByteArray::operator==(
const QString &
s)
const
1403{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) == 0; }
1404bool QByteArray::operator!=(
const QString &
s)
const
1405{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) != 0; }
1406bool QByteArray::operator<(
const QString &
s)
const
1407{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) > 0; }
1408bool QByteArray::operator>(
const QString &
s)
const
1409{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) < 0; }
1410bool QByteArray::operator<=(
const QString &
s)
const
1411{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) >= 0; }
1412bool QByteArray::operator>=(
const QString &
s)
const
1413{
return QString::compare_helper(
s.constData(),
s.size(), constData(),
size()) <= 0; }
1417#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
1421{
return std::move(lhs += rhs); }
1425{
return std::move(lhs += rhs); }
1428# if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
1445{
return toUtf8().toStdString(); }
1448{
return fromUtf8(
s.data(),
qsizetype(
s.size())); }
1459{
return fromWCharArray(
s.data(),
qsizetype(
s.size())); }
1465{
return std::u16string(
reinterpret_cast<const char16_t*
>(
data()),
size()); }
1468{
return fromUcs4(
s.data(),
qsizetype(
s.size())); }
1472 std::u32string u32str(
size(),
char32_t(0));
1473 const qsizetype len = toUcs4_helper(
reinterpret_cast<const char16_t *
>(
data()),
1474 size(), u32str.data());
1479QString::operator std::u16string_view() const noexcept
1481 return std::u16string_view(
d.data(),
size_t(
d.size));
1484#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
1493{
return -
s.compare(*
this, cs); }
1496{
return localeAwareCompare_helper(constData(),
size(),
s.constData(),
s.size()); }
1498{
return localeAwareCompare_helper(
s1.constData(),
s1.size(),
s2.constData(),
s2.size()); }
1502#if QT_CORE_INLINE_IMPL_SINCE(6, 5)
1505 return toIntegral_helper<qlonglong>(*
this,
ok,
base);
1510 return toIntegral_helper<qulonglong>(*
this,
ok,
base);
1513#if QT_CORE_INLINE_IMPL_SINCE(6, 7)
1531# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData()
1534#ifndef qUtf8Printable
1535# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData()
1542#ifndef qUtf16Printable
1543# define qUtf16Printable(string) \
1544 static_cast<const wchar_t*>(static_cast<const void*>(QtPrivate::asString(string).utf16()))
1572template <
typename StringView,
typename...Args>
1586template <
typename...Args>
1593template <
typename...Args>
1600template <
typename T>
1603 return s.removeIf_helper([&
t](
const auto &e) {
return t == e; });
1606template <
typename Predicate>
1609 return s.removeIf_helper(pred);
1613inline namespace Literals {
1614inline namespace StringLiterals {
1625#if QT_DEPRECATED_SINCE(6, 8)
1628inline
QString operator""_qs(const
char16_t *
str,
size_t size) noexcept
1630 return Qt::StringLiterals::operator
""_s(
str,
size);
1638#include <QtCore/qstringbuilder.h>
1639#include <QtCore/qstringconverter.h>
1641#ifdef Q_L1S_VIEW_IS_PRIMARY
1642# undef Q_L1S_VIEW_IS_PRIMARY
constexpr QAnyStringView() noexcept
Constructs a null string view.
constexpr QChar back() const
Returns the last character in the string view.
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QChar front() const
Returns the first character in the string view.
constexpr decltype(auto) visit(Visitor &&v) const
Calls v with either a QUtf8StringView, QLatin1String, or QStringView, depending on the encoding of th...
int compare(QBasicUtf8StringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool equal(QChar other) const noexcept
\inmodule QtCore\reentrant
constexpr const char * data() const noexcept
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString arg(Args &&...args) const
constexpr qsizetype size() const noexcept
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
int localeAwareCompare(QStringView other) const
ushort toUShort(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned short} using base base, which is 10 by default and ...
QString arg(Args &&...args) const
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
int toInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an int using base base, which is 10 by default and must be betwe...
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to a {long long} using base base, which is 10 by default and must b...
ulong toULong(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned long} using base base, which is 10 by default and m...
bool isValidUtf16() const noexcept
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned long long} using base base, which is 10 by default ...
short toShort(bool *ok=nullptr, int base=10) const
Returns the string view converted to a short using base base, which is 10 by default and must be betw...
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
uint toUInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned int} using base base, which is 10 by default and mu...
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
long toLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to a long using base base, which is 10 by default and must be betwe...
qsizetype toWCharArray(wchar_t *array) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString & slice(qsizetype pos)
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
QString & removeAt(qsizetype pos)
std::u32string toStdU32String() const
QByteArray toLatin1() const &
QString left(qsizetype n) &&
QString & operator+=(QStringView v)
const QChar operator[](qsizetype i) const
friend Qt::strong_ordering compareThreeWay(const QString &s1, const QString &s2) noexcept
QT_ASCII_CAST_WARN QString & append(const QByteArray &s)
QString & assign(qsizetype n, QChar c)
void push_front(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
const_iterator constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing just after the last character in...
QString first(qsizetype n) &&
static QString fromLatin1(const char *str, qsizetype size)
Returns a QString initialized with the first size characters of the Latin-1 string str.
const_reverse_iterator rbegin() const
std::wstring toStdWString() const
Returns a std::wstring object with the data contained in this QString.
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
static Q_WEAK_OVERLOAD QString fromLocal8Bit(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QT_ASCII_CAST_WARN QString(const char *ch)
Constructs a string initialized with the 8-bit string str.
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
iterator erase(const_iterator it)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString sliced(qsizetype pos) const &
QString chopped(qsizetype n) const &
static QString fromStdU16String(const std::u16string &s)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & operator+=(QChar c)
const QChar & const_reference
QChar * pointer
The QString::pointer typedef provides an STL-style pointer to a QString element (QChar).
QT_ASCII_CAST_WARN QString(const QByteArray &a)
Constructs a string initialized with the byte array ba.
static QString fromStdString(const std::string &s)
QT_ASCII_CAST_WARN QString & append(const char *s)
QString & operator+=(QUtf8StringView s)
Q_WEAK_OVERLOAD friend Qt::strong_ordering compareThreeWay(const QString &s1, QUtf8StringView s2) noexcept
QString & prepend(const QString &s)
Prepends the string str to the beginning of this string and returns a reference to this string.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
iterator Iterator
Qt-style synonym for QString::iterator.
QString(DataPointer &&dd)
static int compare(QStringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
void push_front(const QString &s)
This function is provided for STL compatibility, prepending the given other string to the beginning o...
QString & prepend(QStringView v)
void clear()
Clears the contents of the string and makes it null.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
friend Qt::strong_ordering compareThreeWay(const QString &lhs, const QByteArray &rhs) noexcept
Q_WEAK_OVERLOAD friend bool comparesEqual(const QString &s1, QUtf8StringView s2) noexcept
ushort toUShort(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned short} using base base, which is 10 by default and must ...
friend Qt::strong_ordering compareThreeWay(const QString &lhs, QChar rhs) noexcept
QString(QString &&other) noexcept=default
Move-constructs a QString instance, making it point at the same object that other was pointing to.
bool isValidUtf16() const noexcept
const_iterator cbegin() const
QString toCaseFolded() const &
static constexpr qsizetype max_size() noexcept
bool isNull() const
Returns true if this string is null; otherwise returns false.
QString right(qsizetype n) &&
qsizetype size() const noexcept
Returns the number of characters in this string.
std::string toStdString() const
Returns a std::string object with the data contained in this QString.
const QChar * const_pointer
The QString::const_pointer typedef provides an STL-style const pointer to a QString element (QChar).
uint toUInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned int} using base base, which is 10 by default and must be...
const_iterator cend() const
void push_back(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QT_ASCII_CAST_WARN QString & operator=(const char *ch)
QString & removeIf(Predicate pred)
QT_ASCII_CAST_WARN QString & operator+=(const char *s)
QStringPrivate DataPointer
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & prepend(QLatin1StringView s)
QT_ASCII_CAST_WARN QString & operator+=(const QByteArray &s)
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString & insert(qsizetype i, const QString &s)
QString & assign(InputIterator first, InputIterator last)
SectionFlag
This enum specifies flags that can be used to affect various aspects of the section() function's beha...
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
constexpr QString() noexcept
Constructs a null string.
bool isSharedWith(const QString &other) const
QT_ASCII_CAST_WARN QString & operator=(const QByteArray &a)
qsizetype capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned long long} using base base, which is 10 by default and m...
QString simplified() const &
const_reverse_iterator crbegin() const
QString & slice(qsizetype pos, qsizetype n)
iterator end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the ...
friend Qt::strong_ordering compareThreeWay(const QString &s1, const char16_t *s2) noexcept
QString sliced(qsizetype pos, qsizetype n) &&
static QString fromLocal8Bit(const char *str, qsizetype size)
Returns a QString initialized with the first size characters of the 8-bit string str.
static int compare(const QString &s1, QLatin1StringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
static int compare(const QString &s1, QStringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
QT_ASCII_CAST_WARN QString & insert(qsizetype i, const QByteArray &s)
long toLong(bool *ok=nullptr, int base=10) const
Returns the string converted to a long using base base, which is 10 by default and must be between 2 ...
QString right(qsizetype n) const &
QT_ASCII_CAST_WARN QString & insert(qsizetype i, const char *s)
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to a {long long} using base base, which is 10 by default and must be bet...
friend Qt::strong_ordering compareThreeWay(const QString &s1, QLatin1StringView s2) noexcept
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
friend bool comparesEqual(const QString &lhs, QByteArrayView rhs) noexcept
std::enable_if< sizeof...(Args)>=2 &&std::is_same< QtPrivate::BoolList< is_convertible_to_view_or_qstring< Args >::value..., true >, QtPrivate::BoolList< true, is_convertible_to_view_or_qstring< Args >::value... > >::value, QString >::type arg(Args &&...args) const
short toShort(bool *ok=nullptr, int base=10) const
Returns the string converted to a short using base base, which is 10 by default and must be between 2...
QT_CORE_INLINE_SINCE(6, 7) qsizetype lastIndexOf(QChar c
static int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
QString & prepend(const QChar *uc, qsizetype len)
QString & operator+=(const QString &s)
Appends the string other onto the end of this string and returns a reference to this string.
QString sliced(qsizetype pos) &&
friend Qt::strong_ordering compareThreeWay(const QString &lhs, QByteArrayView rhs) noexcept
const_reverse_iterator crend() const
QString toLower() const &
qsizetype lastIndexOf(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & append(QStringView v)
QString & insert(qsizetype i, QStringView v)
static QString fromStdU32String(const std::u32string &s)
QByteArray toLocal8Bit() const &
auto tokenize(Needle &&needle, Flags...flags) const &&noexcept(noexcept(qTokenize(std::declval< const QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
const DataPointer & data_ptr() const
void push_back(const QString &s)
This function is provided for STL compatibility, appending the given other string onto the end of thi...
QChar * data()
Returns a pointer to the data stored in the QString.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
QString & operator+=(QLatin1StringView s)
void squeeze()
Releases any memory not required to store the character data.
QString & setUtf16(const ushort *utf16, qsizetype size)
Resizes the string to size characters and copies unicode into the string.
friend bool comparesEqual(const QString &s1, QLatin1StringView s2) noexcept
int localeAwareCompare(const QString &s) const
QT_ASCII_CAST_WARN QString & prepend(const QByteArray &s)
auto tokenize(Needle &&needle, Flags...flags) &&noexcept(noexcept(qTokenize(std::declval< QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
std::u16string toStdU16String() const
QString trimmed() const &
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::reverse_iterator< const_iterator > const_reverse_iterator
QString last(qsizetype n) &&
QT_ASCII_CAST_WARN QString & prepend(const char *s)
ulong toULong(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned long} using base base, which is 10 by default and must b...
static QString fromUtf8(const char *utf8, qsizetype size)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
QByteArray toUtf8() const &
static Q_WEAK_OVERLOAD QString fromLatin1(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString last(qsizetype n) const &
static int localeAwareCompare(const QString &s1, const QString &s2)
Compares s1 with s2 and returns an integer less than, equal to, or greater than zero if s1 is less th...
QString & prepend(QUtf8StringView s)
QStringList split(const QRegularExpression &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts) const
static QString fromStdWString(const std::wstring &s)
Returns a copy of the str string.
QString sliced(qsizetype pos, qsizetype n) const &
QString & prepend(QChar c)
QByteArray toLocal8Bit() &&
auto tokenize(Needle &&needle, Flags...flags) const &noexcept(noexcept(qTokenize(std::declval< const QString & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
QString toUpper() const &
std::reverse_iterator< iterator > reverse_iterator
const_reverse_iterator rend() const
const_iterator constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the st...
QString toCaseFolded() &&
NormalizationForm
This enum describes the various normalized forms of Unicode text.
const_iterator ConstIterator
Qt-style synonym for QString::const_iterator.
qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
static int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
friend Qt::strong_ordering compareThreeWay(const QString &lhs, const char *rhs) noexcept
reverse_iterator rbegin()
const QChar * unicode() const
Returns a Unicode representation of the string.
int compare(QChar ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype length() const noexcept
Returns the number of characters in this string.
const QChar * const_iterator
~QString()
Destroys the string.
friend Qt::strong_ordering compareThreeWay(const QString &s1, std::nullptr_t) noexcept
QString chopped(qsizetype n) &&
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
void resize(qsizetype size)
Sets the size of the string to size characters.
static Q_WEAK_OVERLOAD QString fromUtf8(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
static const strong_ordering greater
static const strong_ordering equivalent
list append(new Employee("Blackpool", "Stephen"))
cache insert(employee->id(), employee)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, char needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT QString convertToQString(QAnyStringView s)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
QStringViewArg qStringLikeToArg(const QString &s) noexcept
qsizetype findString(QStringView str, qsizetype from, QChar needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
std::is_same< Char, char32_t > IsCompatibleChar32TypeHelper
IsCompatibleChar8TypeHelper< q20::remove_cvref_t< Char > > IsCompatibleChar8Type
Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
IsCompatibleChar32TypeHelper< q20::remove_cvref_t< Char > > IsCompatibleChar32Type
constexpr bool isLatin1(QLatin1StringView s) noexcept
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
constexpr T * to_address(T *p) noexcept
qsizetype erase_if(QByteArray &ba, Predicate pred)
qsizetype erase(QByteArray &ba, const T &t)
size_t qstrlen(const char *str)
#define Q_DECLARE_STRONGLY_ORDERED(...)
#define Q_DECL_NS_RETURNS_AUTORELEASED
#define QT_WARNING_DISABLE_INTEL(number)
#define Q_DECL_CF_RETURNS_RETAINED
#define QT_IGNORE_DEPRECATIONS(statement)
#define QT_WARNING_DISABLE_MSVC(number)
#define Q_ATTRIBUTE_FORMAT_PRINTF(A, B)
constexpr bool operator!=(const timespec &t1, const timespec &t2)
constexpr timespec operator+(const timespec &t1, const timespec &t2)
constexpr timespec & operator+=(timespec &t1, const timespec &t2)
AudioChannelLayoutTag tag
#define Q_FORWARD_DECLARE_CF_TYPE(type)
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
bool comparesEqual(const QDir &lhs, const QDir &rhs)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
static T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLint GLenum GLboolean normalized
GLenum GLint GLint * precision
bool operator>(const QPoint &a, const QPoint &b)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
static void split(QT_FT_Vector *b)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static constexpr QChar sep
static QT_BEGIN_NAMESPACE const char * asString(QSSGRenderGraphObject::Type type)
static QChar * fromLocal8Bit(QChar *out, QByteArrayView in, QStringConverter::State *state)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
QBasicUtf8StringView< false > QUtf8StringView
QArrayDataPointer< char16_t > QStringPrivate
constexpr auto qTokenize(Haystack &&h, Needle &&n, Flags...flags) noexcept(QtPrivate::Tok::is_nothrow_constructible_from< Haystack, Needle >::value) -> decltype(QtPrivate::Tok::TokenizerResult< Haystack, Needle >{std::forward< Haystack >(h), std::forward< Needle >(n), flags...})
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
#define QT_ASCII_CAST_WARN
#define QT_DEPRECATED_VERSION_X_6_4(text)
#define QT_DEPRECATED_VERSION_X_6_0(text)
#define QT_DEPRECATED_VERSION_X_6_8(text)
static int compare(quint64 a, quint64 b)
unsigned long long quint64
Qt::weak_ordering compareThreeWay(const QUrl &lhs, const QUrl &rhs)
bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept
static double toDouble(Value v)
settings remove("monkey")
QTextStream out(stdout)
[7]
\inmodule QtCore \reentrant
constexpr QLatin1StringArg(QLatin1StringView v) noexcept
QLatin1StringArg()=default
constexpr QStringViewArg(QStringView v) noexcept