5#ifndef QSTRINGALGORITHMS_H
6#define QSTRINGALGORITHMS_H
8#include <QtCore/qbytearrayalgorithms.h>
9#include <QtCore/qcontainerfwd.h>
10#include <QtCore/qnamespace.h>
11#include <QtCore/qstringfwd.h>
13#pragma qt_class(QStringAlgorithms)
19#include <QtCore/q20type_traits.h>
27[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
const char16_t *
qustrchr(QStringView str,
char16_t ch)
noexcept;
28[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
const char16_t *
qustrcasechr(QStringView str,
char16_t ch)
noexcept;
40[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QStringView lhs, QStringView rhs)
noexcept;
41[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QStringView lhs, QLatin1StringView rhs)
noexcept;
42[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QStringView lhs, QBasicUtf8StringView<
false> rhs)
noexcept;
43[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QLatin1StringView lhs, QStringView rhs)
noexcept;
44[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QLatin1StringView lhs, QLatin1StringView rhs)
noexcept;
45[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QLatin1StringView lhs, QBasicUtf8StringView<
false> rhs)
noexcept;
46[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QBasicUtf8StringView<
false> lhs, QStringView rhs)
noexcept;
47[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QBasicUtf8StringView<
false> lhs, QLatin1StringView rhs)
noexcept;
48[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool equalStrings(QBasicUtf8StringView<
false> lhs, QBasicUtf8StringView<
false> rhs)
noexcept;
55[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
noexcept;
56[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool endsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
noexcept;
57[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool endsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
noexcept;
58[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool endsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs =
Qt::
CaseSensitive)
noexcept;
75[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool isLower(QStringView s)
noexcept;
76[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool isUpper(QStringView s)
noexcept;
85#if QT_CONFIG(regularexpression)
127[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool isAscii(QLatin1StringView s)
noexcept;
128[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool isAscii(QStringView s)
noexcept;
130[[
nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
bool isLatin1(QStringView s)
noexcept;
133template <
typename Char, size_t N> [[nodiscard]] Q_ALWAYS_INLINE
constexpr
136#if defined(__cpp_lib_constexpr_algorithms) && defined(Q_CC_GNU_ONLY)
160#if defined(Q_CC_CLANG)
163#elif defined(Q_CC_GNU)
171 if constexpr (
N == 1) {
172 return str[0] ==
Char(0) ? 0 : 1;
174#ifdef QT_SUPPORTS_IS_CONSTANT_EVALUATED
185#if !defined(Q_COMPILER_SLOW_QSTRNLEN_COMPILATION)
186 return qstrnlen(str, maxlen);
188 return strnlen_s(str, maxlen);
192template <
typename Char, size_t N> [[nodiscard]]
constexpr inline
195#ifdef QT_SUPPORTS_IS_CONSTANT_EVALUATED
196 if (!q20::is_constant_evaluated())
197 return qstrnlen_helper(
reinterpret_cast<
const char *>(str), N);
200 return lengthHelperContainerLoop(str);
203template <
typename Container>
206 return qsizetype(
std::size(c));
~QStringTokenizerBaseBase()=default
constexpr QStringTokenizerBaseBase(Qt::SplitBehavior sb, Qt::CaseSensitivity cs) noexcept
friend constexpr bool operator!=(const iterator &lhs, sentinel) noexcept
const value_type * pointer
const value_type & reference
constexpr const Haystack * operator->() const
friend constexpr bool operator==(const iterator &lhs, sentinel) noexcept
iterator() noexcept=default
constexpr const Haystack & operator*() const
std::forward_iterator_tag iterator_category
friend constexpr bool operator!=(sentinel, const iterator &rhs) noexcept
friend constexpr bool operator==(sentinel, const iterator &rhs) noexcept
friend constexpr bool operator==(sentinel, sentinel) noexcept
friend constexpr bool operator!=(sentinel, sentinel) noexcept
typename iterator::pointer pointer
constexpr sentinel end() const noexcept
iterator begin() const noexcept
typename iterator::difference_type difference_type
constexpr QStringTokenizerBase(Haystack haystack, Needle needle, Qt::SplitBehavior sb, Qt::CaseSensitivity cs) noexcept
iterator cbegin() const noexcept
typename iterator::reference reference
typename iterator::value_type value_type
reference const_reference
constexpr sentinel cend() const noexcept
Container toContainer(Container &&c={}) const &&
Container toContainer(Container &&c={}) const &
constexpr QStringTokenizer(Haystack haystack, Needle needle, Qt::CaseSensitivity cs, Qt::SplitBehavior sb=Qt::KeepEmptyParts) noexcept(std::is_nothrow_copy_constructible< QStringTokenizer >::value)
\typealias QStringTokenizer::sentinel
constexpr qsizetype tokenSize(const String &s) noexcept
typename ViewForImpl< typename std::decay< String >::type >::type ViewFor
constexpr qsizetype tokenSize(QChar) noexcept
typename PinForImpl< typename std::remove_cv< StringLike >::type >::type PinFor
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
constexpr qsizetype lengthHelperContainer(const Container &c) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLower(QStringView s) noexcept
constexpr std::enable_if_t< sizeof(Char)==1, qsizetype > lengthHelperContainer(const Char(&str)[N])
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) 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 bool isRightToLeft(QStringView string) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
qsizetype qstrnlen_helper(const char *str, size_t maxlen)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1StringView s) noexcept
constexpr bool isLatin1(QLatin1StringView s) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrcasechr(QStringView str, char16_t ch) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isUpper(QStringView s) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrchr(QStringView str, char16_t ch) noexcept
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...})
friend constexpr bool operator!=(tokenizer_state lhs, tokenizer_state rhs) noexcept
friend constexpr bool operator==(tokenizer_state lhs, tokenizer_state rhs) noexcept
constexpr auto haystackView(Arg &&a) noexcept -> decltype(this->view(std::forward< Arg >(a)))
constexpr auto needleView(Arg &&a) noexcept -> decltype(this->view(std::forward< Arg >(a)))
std::basic_string< Char, Args... > type
constexpr QStringView view(const T &) const noexcept
constexpr Pinning(T &&s) noexcept
constexpr Pinning(const T &) noexcept
constexpr T view(T t) const noexcept