53 #ifndef QT_STRINGVIEW_LEVEL
54 # define QT_STRINGVIEW_LEVEL 1
57 #include <QtCore/qchar.h>
58 #include <QtCore/qbytearray.h>
59 #include <QtCore/qstringliteral.h>
60 #include <QtCore/qstringalgorithms.h>
64 #if defined(Q_OS_DARWIN) || defined(Q_QDOC)
77 template <
typename Char>
79 : std::integral_constant<bool,
80 std::is_same<Char, QChar>::value ||
81 std::is_same<Char, ushort>::value ||
82 std::is_same<Char, char16_t>::value ||
83 (std::is_same<Char, wchar_t>::value && sizeof(wchar_t) == sizeof(QChar))> {};
84 template <
typename Char>
88 template <
typename Po
inter>
90 template <
typename Char>
93 template <
typename Po
inter>
97 template <
typename T,
typename Enable =
void>
100 template <
typename T>
103 IsCompatiblePointer<decltype( std::data(std::declval<const T &>()) )>,
105 std::is_convertible<decltype( std::size(std::declval<const T &>()) ), qsizetype>,
107 IsCompatibleCharType<typename std::iterator_traits<decltype( std::begin(std::declval<const T &>()) )>::value_type>,
109 decltype( std::begin(std::declval<const T &>()) != std::end(std::declval<const T &>()) ),
113 std::negation<std::is_same<std::decay_t<T>, QString>>,
116 std::negation<std::is_same<std::decay_t<T>, QStringView>>
117 >>> : std::true_type {};
139 template <
typename Char>
142 template <
typename Po
inter>
145 template <
typename T>
148 template <
typename T>
151 template <
typename Char>
154 #if defined(__cpp_lib_is_constant_evaluated)
155 if (std::is_constant_evaluated())
157 #elif defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
158 if (__builtin_constant_p(*
str))
168 template <
typename Container>
174 template <
typename Char,
size_t N>
182 template <
typename Char>
190 : m_size(0), m_data(
nullptr) {}
194 template <
typename Char, if_compatible_
char<Char> = true>
197 m_data(castHelper(
str)) {}
199 template <
typename Char, if_compatible_
char<Char> = true>
204 template <
typename Char,
size_t N>
207 template <
typename Char>
211 template <
typename Po
inter, if_compatible_po
inter<Po
inter> = true>
219 template <
typename String, if_compatible_q
string_like<String> = true>
224 template <
typename Container, if_compatible_container<Container> = true>
228 template <
typename Char,
size_t Size, if_compatible_
char<Char> = true>
233 #if defined(Q_OS_DARWIN) || defined(Q_QDOC)
251 template <
typename...Args>
269 if (
size_t(
n) >=
size_t(
size()))
275 if (
size_t(
n) >=
size_t(
size()))
298 template <
typename Needle,
typename...Flags>
302 {
return qTokenize(*
this, std::forward<Needle>(needle),
flags...); }
308 {
return size() >= 1 ? compare_single_char_helper(*
utf16() -
c.unicode()) : -1; }
356 #if QT_CONFIG(regularexpression)
365 template <
typename T = QRegularExpressionMatch, std::enable_if_t<std::is_same_v<T, QRegularExpressionMatch>,
bool> = false>
390 [[nodiscard]]
inline short toShort(
bool *
ok =
nullptr,
int base = 10)
const;
392 [[nodiscard]]
inline int toInt(
bool *
ok =
nullptr,
int base = 10)
const;
394 [[nodiscard]]
inline long toLong(
bool *
ok =
nullptr,
int base = 10)
const;
398 [[nodiscard]] Q_CORE_EXPORT
float toFloat(
bool *
ok =
nullptr)
const;
399 [[nodiscard]] Q_CORE_EXPORT
double toDouble(
bool *
ok =
nullptr)
const;
404 [[nodiscard]] Q_CORE_EXPORT
408 [[nodiscard]] Q_CORE_EXPORT
412 #if QT_CONFIG(regularexpression)
413 [[nodiscard]] Q_CORE_EXPORT
462 [[nodiscard]] constexpr
bool isNull()
const noexcept {
return !m_data; }
472 constexpr
int compare_single_char_helper(
int diff)
const noexcept
473 {
return diff ? diff :
size() > 1 ? 1 : 0; }
477 template <
typename QStringLike,
typename std::enable_if<
490 [[nodiscard]] constexpr
qsizetype size()
const noexcept {
return chars[1] ? 2 : 1; }
491 [[nodiscard]] constexpr
const char16_t *
begin()
const noexcept {
return chars; }
492 [[nodiscard]] constexpr
const char16_t *
end()
const noexcept {
return begin() +
size(); }
496 R{{char16_t(
c),
u'\0'}} ;
small capitals from c petite p scientific f u
The QByteArray class provides an array of bytes.
The QChar class provides a 16-bit Unicode character.
static constexpr auto fromUcs4(char32_t c) noexcept
static constexpr char16_t highSurrogate(char32_t ucs4) noexcept
static constexpr char16_t lowSurrogate(char32_t ucs4) noexcept
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QRegularExpression class provides pattern matching using regular expressions.
The QRegularExpressionMatch class provides the results of a matching a QRegularExpression against a s...
The QString class provides a Unicode character string.
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
const_iterator cend() const noexcept
friend bool operator!=(QStringView lhs, QStringView rhs) noexcept
bool startsWith(QChar c) const noexcept
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Q_CORE_EXPORT double toDouble(bool *ok=nullptr) const
constexpr void truncate(qsizetype n) noexcept
bool isRightToLeft() const noexcept
const_iterator cbegin() const noexcept
int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
Q_CORE_EXPORT float toFloat(bool *ok=nullptr) const
friend bool operator>=(QStringView lhs, QChar rhs) noexcept
friend bool operator!=(QChar lhs, QStringView rhs) noexcept
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
friend bool operator<=(QChar lhs, QStringView rhs) noexcept
constexpr const storage_type * utf16() const noexcept
bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
constexpr QChar front() const
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr qsizetype length() const noexcept
constexpr void chop(qsizetype n) noexcept
constexpr auto tokenize(Needle &&needle, Flags...flags) const noexcept(noexcept(qTokenize(std::declval< const QStringView & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
constexpr bool isEmpty() const noexcept
ushort toUShort(bool *ok=nullptr, int base=10) const
const_pointer const_iterator
QString arg(Args &&...args) const
const_reverse_iterator rbegin() const noexcept
constexpr qsizetype size() const noexcept
friend bool operator<(QStringView lhs, QStringView rhs) noexcept
friend bool operator==(QStringView lhs, QStringView rhs) noexcept
const_iterator constEnd() const noexcept
constexpr QStringView first(qsizetype n) const noexcept
constexpr QStringView chopped(qsizetype n) const noexcept
const_reverse_iterator crend() const noexcept
value_type & const_reference
qsizetype count(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QChar last() const
constexpr QStringView left(qsizetype n) const noexcept
qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
const_iterator begin() const noexcept
QList< uint > toUcs4() const
friend bool operator>(QStringView lhs, QStringView rhs) noexcept
QByteArray toLatin1() const
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QByteArray toUtf8() const
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QByteArray toLocal8Bit() const
bool endsWith(QChar c) const noexcept
bool contains(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
const_reverse_iterator rend() const noexcept
std::ptrdiff_t difference_type
int toInt(bool *ok=nullptr, int base=10) const
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
constexpr QStringView(const Container &c) noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr QStringView last(qsizetype n) const noexcept
const_pointer data() const noexcept
constexpr QStringView() noexcept
constexpr QChar operator[](qsizetype n) const
friend bool operator<=(QStringView lhs, QChar rhs) noexcept
constexpr bool empty() const noexcept
ulong toULong(bool *ok=nullptr, int base=10) const
constexpr QChar back() const
bool isValidUtf16() const noexcept
constexpr bool isNull() const noexcept
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
short toShort(bool *ok=nullptr, int base=10) const
constexpr QStringView right(qsizetype n) const noexcept
const_reverse_iterator crbegin() const noexcept
constexpr QChar at(qsizetype n) const noexcept
constexpr int compare(QChar c) const noexcept
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
qsizetype indexOf(QStringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView sliced(qsizetype pos) const noexcept
friend bool operator==(QChar lhs, QStringView rhs) noexcept
friend bool operator==(QStringView lhs, QChar rhs) noexcept
constexpr static QStringView fromArray(const Char(&string)[Size]) noexcept
value_type * const_pointer
QStringView trimmed() const noexcept
friend bool operator>=(QStringView lhs, QStringView rhs) noexcept
const_iterator constBegin() const noexcept
friend bool operator!=(QStringView lhs, QChar rhs) noexcept
constexpr QStringView sliced(qsizetype pos, qsizetype n) const noexcept
const_iterator end() const noexcept
friend bool operator<=(QStringView lhs, QStringView rhs) noexcept
const_pointer constData() const noexcept
friend bool operator>=(QChar lhs, QStringView rhs) noexcept
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView(std::nullptr_t) noexcept
uint toUInt(bool *ok=nullptr, int base=10) const
constexpr QStringView(const Char *f, const Char *l)
qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView(const Char *str, qsizetype len)
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
long toLong(bool *ok=nullptr, int base=10) const
std::reverse_iterator< iterator > reverse_iterator
qsizetype toWCharArray(wchar_t *array) const
constexpr QStringView(const Pointer &str) noexcept
constexpr QChar first() const
QStringView(const String &str) noexcept
auto it unsigned count const
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const char16_t *str) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) 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 QByteArray convertToUtf8(QStringView str)
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 int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
qsizetype indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
int distance(TestIterator &a, TestIterator &b)
#define Q_DECL_NS_RETURNS_AUTORELEASED
#define Q_DECL_CF_RETURNS_RETAINED
Q_FORWARD_DECLARE_OBJC_CLASS(NSObject)
Q_FORWARD_DECLARE_CF_TYPE(CTFontDescriptor)
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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
Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE)
QT_BEGIN_NAMESPACE typedef char Char
QDomElement find(const QString &tagName, const QDomElement &e)