3#ifndef QSTRINGTOKENIZER_H
4#define QSTRINGTOKENIZER_H
6#include <QtCore/qnamespace.h>
7#include <QtCore/qcontainerfwd.h>
14#define Q_STRINGTOKENIZER_USE_SENTINEL
26 {
return lhs.start == rhs.start && lhs.end == rhs.end && lhs.extra == rhs.extra; }
35template <
typename Haystack,
typename Needle>
44 inline next_result toFront()
const noexcept {
return next({}); }
51#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
64 : tokenizer{&
t}, current{
t.toFront()} {}
75 [[nodiscard]] constexpr const Haystack* operator->()
const {
return Q_ASSERT(current.ok), ¤t.value; }
82 {
return lhs.current.ok == rhs.current.ok && (!lhs.current.ok || (
Q_ASSERT(lhs.tokenizer == rhs.tokenizer), lhs.current.state == rhs.current.state)); }
85#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
87 {
return !lhs.current.ok; }
91 {
return !rhs.current.ok; }
98 current = tokenizer->next(current.state);
113 template <bool = std::is_same<iterator, sentinel>::value>
114 [[nodiscard]]
constexpr sentinel end() const noexcept {
return {}; }
115 template <bool = std::is_same<iterator, sentinel>::value>
124#include <QtCore/qstringview.h>
131 template <
typename String>
141 template <>
struct ViewForImpl<char16_t*> : ViewForImpl<QStringView> {};
142 template <>
struct ViewForImpl<const char16_t*> : ViewForImpl<QStringView> {};
143 template <
typename LHS,
typename RHS>
145 template <
typename Char,
typename...Args>
147#ifdef __cpp_lib_string_view
148 template <
typename Char,
typename...Args>
156 template <
typename String>
157 using ViewFor =
typename ViewForImpl<typename std::decay<String>::type>
::type;
165 template <
typename String>
173 template <
typename Char,
typename...Args>
175 {
using type = std::basic_string<
Char, Args...>; };
178 template <
typename LHS,
typename RHS>
180 :
PinForImpl<typename QStringBuilder<LHS, RHS>::ConvertTo> {};
182 template <
typename StringLike>
183 using PinFor =
typename PinForImpl<typename std::remove_cv<StringLike>::type>
::type;
190 template <typename T, bool pinned = is_owning_string_type<T>::value>
197 constexpr T
view(T
t)
const noexcept {
return t; }
201 template <
typename T>
207 constexpr Pinning(T &&
s) noexcept : m_string{std::move(
s)} {}
215 template <
typename T>
219 template <
typename Arg>
221 ->
decltype(this->
view(std::forward<Arg>(
a)))
222 {
return this->
view(std::forward<Arg>(
a)); }
225 template <
typename T>
229 template <
typename Arg>
231 ->
decltype(this->
view(std::forward<Arg>(
a)))
232 {
return this->
view(std::forward<Arg>(
a)); }
240 template <
typename Haystack,
typename Needle>
241 using TokenizerBase = QStringTokenizerBase<ViewFor<Haystack>, ViewFor<Needle>>;
245template <
typename Haystack,
typename Needle>
254 template <
typename Container,
typename HPin>
255 struct if_haystack_not_pinned_impl : std::enable_if<std::is_empty<HPin>::value, bool> {};
256 template <
typename Container>
257 using if_haystack_not_pinned =
typename if_haystack_not_pinned_impl<Container, HPin>::type;
258 template <typename Container, typename Iterator = decltype(std::begin(std::declval<Container>()))>
259 using if_compatible_container =
typename std::enable_if<
262 typename std::iterator_traits<Iterator>::value_type
281 [[nodiscard]]
constexpr sentinel end() const noexcept {
return {}; }
282 [[nodiscard]]
constexpr sentinel cend() const noexcept {
return {}; }
288 noexcept(std::is_nothrow_copy_constructible<QStringTokenizer>::value)
293 :
HPin{
std::forward<Haystack>(haystack)},
294 NPin{
std::forward<Needle>(needle)},
303 noexcept(std::is_nothrow_copy_constructible<QStringTokenizer>::value)
304 :
HPin{
std::forward<Haystack>(haystack)},
305 NPin{
std::forward<Needle>(needle)},
311 template<
typename LContainer> LContainer
toContainer(LContainer &&
c = {})
const & {}
312 template<
typename RContainer> RContainer
toContainer(RContainer &&
c = {})
const && {}
314 template<
typename Container = QList<value_type>, if_compatible_container<Container> = true>
319 return std::forward<Container>(
c);
321 template<
typename Container = QList<value_type>, if_compatible_container<Container> = true,
322 if_haystack_not_pinned<Container> = true>
327 return std::forward<Container>(
c);
345#define Q_TOK_RESULT \
347 QtPrivate::Tok::PinFor<Haystack>, \
348 QtPrivate::Tok::PinFor<Needle> \
351template <
typename Haystack,
typename Needle>
353template <
typename Haystack,
typename Needle>
358#ifdef __cpp_deduction_guides
361template <
typename Haystack,
typename Needle>
364template <
typename Haystack,
typename Needle>
367template <
typename Haystack,
typename Needle>
370template <
typename Haystack,
typename Needle>
373template <
typename Haystack,
typename Needle>
380template <
typename Haystack,
typename Needle,
typename...Flags>
381[[nodiscard]]
constexpr auto
383 noexcept(
QtPrivate::Tok::is_nothrow_constructible_from<Haystack, Needle>::
value)
384 -> decltype(
QtPrivate::Tok::TokenizerResult<Haystack, Needle>{std::forward<Haystack>(
h),
385 std::forward<Needle>(
n),
flags...})
387 std::forward<Needle>(
n),
390template <
typename Haystack,
typename Needle>
396 return {{},
false,
state};
400 if (
state.end >= 0) {
405 state.extra = (
ns == 0 ? 1 : 0);
~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, const iterator &rhs) noexcept
friend constexpr bool operator==(const iterator &lhs, sentinel) noexcept
iterator() noexcept=default
constexpr const Haystack & operator*() const
friend constexpr bool operator!=(const iterator &lhs, const iterator &rhs) noexcept
std::forward_iterator_tag iterator_category
qsizetype difference_type
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 cend() 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
constexpr sentinel end() const noexcept
typename iterator::reference reference
typename iterator::value_type value_type
reference const_reference
typename Base::sentinel sentinel
typename Base::const_reference const_reference
typename Base::iterator iterator
typename Base::const_pointer const_pointer
constexpr QStringTokenizer(Haystack haystack, Needle needle, Qt::SplitBehavior sb=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept(std::is_nothrow_copy_constructible< QStringTokenizer >::value)
Constructs a string tokenizer that splits the string haystack into substrings wherever needle occurs,...
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
typename Base::value_type value_type
typename Base::reference reference
typename Base::size_type size_type
Container toContainer(Container &&c={}) const &&
Container toContainer(Container &&c={}) const &
typename Base::pointer pointer
typename Base::const_iterator const_iterator
\typealias QStringTokenizer::value_type
typename Base::difference_type difference_type
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
Q_TOK_RESULT TokenizerResult
constexpr qsizetype size(QChar) noexcept
typename ViewForImpl< typename std::decay< String >::type >::type ViewFor
std::is_nothrow_copy_constructible< TokenizerResult< Haystack, Needle > > is_nothrow_constructible_from
typename PinForImpl< typename std::remove_cv< StringLike >::type >::type PinFor
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat h
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_BEGIN_INCLUDE_NAMESPACE
#define QT_END_INCLUDE_NAMESPACE
\inmodule QtCore \reentrant
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