7#ifndef QLATIN1STRINGVIEW_H
8#define QLATIN1STRINGVIEW_H
10#include <QtCore/qchar.h>
11#include <QtCore/qnamespace.h>
12#include <QtCore/qtversionchecks.h>
13#include <QtCore/qstringview.h>
17#pragma qt_class(QLatin1String)
18#pragma qt_class(QLatin1StringView)
25#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) || defined(Q_QDOC)
26# define Q_L1S_VIEW_IS_PRIMARY
33#ifdef Q_L1S_VIEW_IS_PRIMARY
46 constexpr QLatin1String() noexcept : m_size(0), m_data(
nullptr) {}
60 constexpr const char *
latin1() const noexcept {
return m_data; }
62 constexpr const char *
data() const noexcept {
return m_data; }
63 [[nodiscard]]
constexpr const char *
constData() const noexcept {
return data(); }
64 [[nodiscard]]
constexpr const char *
constBegin() const noexcept {
return begin(); }
65 [[nodiscard]]
constexpr const char *
constEnd() const noexcept {
return end(); }
72 constexpr bool isNull() const noexcept {
return !
data(); }
75 [[nodiscard]]
constexpr bool empty() const noexcept {
return size() == 0; }
77 template <
typename...Args>
174 return r.value_or(0.0f);
181 return r.value_or(0.0);
214 if (
size_t(
n) >=
size_t(
size()))
220 if (
size_t(
n) >=
size_t(
size()))
222 return {m_data + m_size -
n,
n};
226 { verify(
pos);
return {m_data +
pos, m_size -
pos}; }
228 { verify(
pos,
n);
return {m_data +
pos,
n}; }
230 { verify(
n);
return {m_data,
n}; }
232 { verify(
n);
return {m_data +
size() -
n,
n}; }
234 { verify(
n);
return {m_data,
size() -
n}; }
237 { verify(
n); m_size -=
n; }
239 { verify(
n); m_size =
n; }
243 template <
typename Needle,
typename...Flags>
246 std::forward<Needle>(needle),
flags...)))
248 {
return qTokenize(*
this, std::forward<Needle>(needle),
flags...); }
253 {
return !(
s1 ==
s2); }
257 const int r =
len ? memcmp(
s1.latin1(),
s2.latin1(),
len) : 0;
258 return r < 0 || (
r == 0 &&
s1.size() <
s2.size());
263 {
return !(
s1 >
s2); }
265 {
return !(
s1 <
s2); }
300#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
334 Q_CORE_EXPORT
static int compare_helper(
const QChar *data1,
qsizetype length1,
337#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED)
338 const char *m_data =
nullptr;
345#ifdef Q_L1S_VIEW_IS_PRIMARY
352inline namespace Literals {
353inline namespace StringLiterals {
366#ifdef Q_L1S_VIEW_IS_PRIMARY
367# undef Q_L1S_VIEW_IS_PRIMARY
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr int compare(QChar c) const noexcept
QT_ASCII_CAST_WARN friend bool operator>=(const char *s1, QLatin1StringView s2)
qsizetype count(QChar ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
friend bool operator<=(QLatin1StringView s1, QLatin1StringView s2) noexcept
QT_ASCII_CAST_WARN friend bool operator==(const char *s1, QLatin1StringView s2)
constexpr QLatin1Char back() const
constexpr const char * data() const noexcept
constexpr const char * constBegin() const noexcept
friend bool operator<=(QChar lhs, QLatin1StringView rhs) noexcept
friend bool operator!=(QLatin1StringView lhs, QChar rhs) noexcept
qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QT_ASCII_CAST_WARN friend bool operator<=(const char *s1, QLatin1StringView s2)
friend bool operator>=(QLatin1StringView lhs, QStringView rhs) noexcept
friend bool operator==(QChar lhs, QLatin1StringView rhs) noexcept
ulong toULong(bool *ok=nullptr, int base=10) const
const_reverse_iterator rend() const noexcept
constexpr bool isEmpty() const noexcept
friend bool operator>=(QLatin1StringView s1, QLatin1StringView s2) noexcept
short toShort(bool *ok=nullptr, int base=10) const
std::reverse_iterator< iterator > reverse_iterator
friend bool operator<=(QLatin1StringView lhs, QStringView rhs) noexcept
constexpr qsizetype length() const noexcept
constexpr const char * latin1() const noexcept
friend bool operator>=(QChar lhs, QLatin1StringView rhs) noexcept
qsizetype difference_type
constexpr QLatin1StringView last(qsizetype n) const
constexpr const_iterator cbegin() const noexcept
constexpr bool endsWith(QChar c) const 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...))
friend bool operator<=(QStringView lhs, QLatin1StringView rhs) noexcept
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
friend bool operator==(QLatin1StringView lhs, QStringView rhs) 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 operator>(QLatin1StringView s1, QLatin1StringView s2) noexcept
constexpr void chop(qsizetype n)
friend bool operator!=(QStringView lhs, QLatin1StringView rhs) noexcept
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
friend bool operator>=(QStringView lhs, QLatin1StringView rhs) 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
friend bool operator!=(QChar lhs, QLatin1StringView rhs) noexcept
friend bool operator!=(QLatin1StringView s1, QLatin1StringView s2) noexcept
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
friend bool operator==(QLatin1StringView lhs, QChar rhs) 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 bool operator==(QStringView lhs, QLatin1StringView rhs) noexcept
constexpr QLatin1StringView(const char *s, qsizetype sz) noexcept
friend bool operator!=(QLatin1StringView lhs, QStringView rhs) noexcept
friend bool operator>=(QLatin1StringView lhs, QChar rhs) noexcept
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype count(QLatin1StringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
friend bool operator==(QLatin1StringView s1, QLatin1StringView s2) noexcept
constexpr QLatin1Char operator[](qsizetype i) const
constexpr const_iterator begin() const noexcept
constexpr QLatin1StringView first(qsizetype n) const
const_reverse_iterator rbegin() const noexcept
uint toUInt(bool *ok=nullptr, int base=10) const
QT_ASCII_CAST_WARN friend bool operator!=(const char *s1, QLatin1StringView s2)
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
friend bool operator<(QLatin1StringView s1, QLatin1StringView s2) 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
friend bool operator<=(QLatin1StringView lhs, QChar rhs) noexcept
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
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 lastIndexOf(QByteArrayView haystack, qsizetype from, 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
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView 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
size_t qstrlen(const char *str)
constexpr const T & qMin(const T &a, const T &b)
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