7#ifndef QLATIN1STRINGVIEW_H
8#define QLATIN1STRINGVIEW_H
10#include <QtCore/qchar.h>
11#include <QtCore/qcompare.h>
12#include <QtCore/qnamespace.h>
13#include <QtCore/qtversionchecks.h>
14#include <QtCore/qstringview.h>
18#pragma qt_class(QLatin1String)
19#pragma qt_class(QLatin1StringView)
26#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) || defined(Q_QDOC)
27# define Q_L1S_VIEW_IS_PRIMARY
34#ifdef Q_L1S_VIEW_IS_PRIMARY
47 constexpr QLatin1String() noexcept : m_size(0), m_data(
nullptr) {}
61 constexpr const char *
latin1() const noexcept {
return m_data; }
63 constexpr const char *
data() const noexcept {
return m_data; }
64 [[nodiscard]]
constexpr const char *
constData() const noexcept {
return data(); }
65 [[nodiscard]]
constexpr const char *
constBegin() const noexcept {
return begin(); }
66 [[nodiscard]]
constexpr const char *
constEnd() const noexcept {
return end(); }
73 constexpr bool isNull() const noexcept {
return !
data(); }
76 [[nodiscard]]
constexpr bool empty() const noexcept {
return size() == 0; }
78 template <
typename...Args>
175 return r.value_or(0.0f);
182 return r.value_or(0.0);
217 if (
size_t(
n) >=
size_t(
size()))
223 if (
size_t(
n) >=
size_t(
size()))
225 return {m_data + m_size -
n,
n};
229 { verify(
pos, 0);
return {m_data +
pos, m_size -
pos}; }
231 { verify(
pos,
n);
return {m_data +
pos,
n}; }
233 { verify(0,
n);
return sliced(0,
n); }
240 { verify(0,
n); m_size -=
n; }
242 { verify(0,
n); m_size =
n; }
246 template <
typename Needle,
typename...Flags>
249 std::forward<Needle>(needle),
flags...)))
251 {
return qTokenize(*
this, std::forward<Needle>(needle),
flags...); }
265 {
return lhs.size() == 1 && rhs == lhs.front(); }
270 const int res = -compare_helper(&rhs, 1, lhs);
298 {
return equal_helper(lhs, rhs.data(), rhs.size()); }
302 const int res = compare_helper(lhs, rhs.data(), rhs.size());
316#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
335 Q_CORE_EXPORT
static int compare_helper(
const QChar *data1,
qsizetype length1,
338#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED)
339 const char *m_data =
nullptr;
346#ifdef Q_L1S_VIEW_IS_PRIMARY
357inline namespace Literals {
358inline namespace StringLiterals {
371#ifdef Q_L1S_VIEW_IS_PRIMARY
372# undef Q_L1S_VIEW_IS_PRIMARY
constexpr QByteArrayView() noexcept
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr int compare(QChar c) const noexcept
friend Qt::strong_ordering compareThreeWay(const QLatin1StringView &s1, const QLatin1StringView &s2) noexcept
qsizetype count(QChar ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
friend Qt::strong_ordering compareThreeWay(const QLatin1StringView &lhs, const QByteArrayView &rhs) noexcept
constexpr QLatin1Char back() const
friend bool comparesEqual(const QLatin1StringView &s1, const QLatin1StringView &s2) noexcept
constexpr const char * data() const noexcept
constexpr const char * constBegin() const noexcept
friend Qt::strong_ordering compareThreeWay(const QStringView &lhs, const QLatin1StringView &rhs) noexcept
qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
ulong toULong(bool *ok=nullptr, int base=10) const
const_reverse_iterator rend() const noexcept
constexpr bool isEmpty() const noexcept
friend Qt::strong_ordering compareThreeWay(const QLatin1StringView &lhs, QChar rhs) noexcept
short toShort(bool *ok=nullptr, int base=10) const
std::reverse_iterator< iterator > reverse_iterator
constexpr qsizetype length() const noexcept
constexpr const char * latin1() const noexcept
qsizetype difference_type
constexpr QLatin1StringView last(qsizetype n) const
constexpr const_iterator cbegin() const noexcept
constexpr bool endsWith(QChar c) const noexcept
friend bool comparesEqual(const QLatin1StringView &lhs, const QByteArrayView &rhs) noexcept
constexpr const char * constData() const noexcept
constexpr auto tokenize(Needle &&needle, Flags...flags) const noexcept(noexcept(qTokenize(std::declval< const QLatin1StringView & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
const_reverse_iterator crend() const noexcept
constexpr QLatin1StringView mid(qsizetype pos, qsizetype n=-1) const
bool contains(QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QLatin1StringView(const char *f, const char *l)
constexpr bool isNull() const noexcept
constexpr QLatin1Char front() const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
constexpr QLatin1StringView left(qsizetype n) const
qsizetype count(QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr const_iterator end() const noexcept
const_reverse_iterator crbegin() const noexcept
QLatin1StringView trimmed() const noexcept
int toInt(bool *ok=nullptr, int base=10) const
friend bool comparesEqual(const QByteArrayView &lhs, const QLatin1StringView &rhs) noexcept
constexpr void chop(qsizetype n)
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QLatin1Char last() const
constexpr QLatin1StringView right(qsizetype n) const
constexpr QLatin1Char first() const
constexpr bool empty() const noexcept
qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
long toLong(bool *ok=nullptr, int base=10) const
constexpr const_iterator cend() const noexcept
float toFloat(bool *ok=nullptr) const
constexpr QLatin1StringView(const char *s) noexcept
QLatin1StringView(const QByteArray &s) noexcept
constexpr QLatin1StringView sliced(qsizetype pos) const
constexpr QLatin1Char at(qsizetype i) const
bool contains(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QLatin1StringView chopped(qsizetype n) const
constexpr QLatin1StringView sliced(qsizetype pos, qsizetype n) const
friend Qt::strong_ordering compareThreeWay(const QByteArrayView &lhs, const QLatin1StringView &rhs) noexcept
constexpr QLatin1StringView(const char *s, qsizetype sz) noexcept
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype count(QLatin1StringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
constexpr QLatin1Char operator[](qsizetype i) const
constexpr const_iterator begin() const noexcept
constexpr QLatin1StringView first(qsizetype n) const
friend Qt::strong_ordering compareThreeWay(const QLatin1StringView &lhs, const QStringView &rhs) noexcept
const_reverse_iterator rbegin() const noexcept
uint toUInt(bool *ok=nullptr, int base=10) const
QString arg(Args &&...args) const
constexpr qsizetype size() const noexcept
reverse_iterator const_reverse_iterator
qsizetype indexOf(QStringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QLatin1StringView(std::nullptr_t) noexcept
constexpr bool startsWith(QChar c) const noexcept
constexpr const char * constEnd() const noexcept
qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
double toDouble(bool *ok=nullptr) const
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr void truncate(qsizetype n)
constexpr QLatin1StringView() noexcept
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
constexpr QLatin1StringView(QByteArrayView s) noexcept
int compare(QLatin1StringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
reference const_reference
ushort toUShort(bool *ok=nullptr, int base=10) const
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
Combined button and popup list for selecting options.
constexpr O reversed(O o) noexcept
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 Q_DECL_PURE_FUNCTION QByteArrayView trimmed(QByteArrayView s) noexcept
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
qsizetype findString(QStringView str, qsizetype from, QChar needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION ParsedNumber< float > toFloat(QByteArrayView a) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION ParsedNumber< double > toDouble(QByteArrayView a) noexcept
static constexpr qsizetype lengthHelperPointer(const Char *data) noexcept
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
size_t qstrlen(const char *str)
#define Q_DECLARE_STRONGLY_ORDERED(...)
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
QLatin1StringView QLatin1String
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...})
#define QT_ASCII_CAST_WARN
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
\inmodule QtCore \reentrant