3#ifndef QSTRINGTOKENIZER_H
4#define QSTRINGTOKENIZER_H
6#include <QtCore/qnamespace.h>
7#include <QtCore/qcontainerfwd.h>
13#define Q_STRINGTOKENIZER_USE_SENTINEL
25 {
return lhs.start == rhs.start && lhs.end == rhs.end && lhs.extra == rhs.extra; }
34template <
typename Haystack,
typename Needle>
43 inline next_result toFront()
const noexcept {
return next({}); }
50#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
56 using sentinel = iterator;
63 : tokenizer{&
t}, current{
t.toFront()} {}
74 [[nodiscard]] constexpr const Haystack* operator->()
const {
return Q_ASSERT(current.ok), ¤t.value; }
81 {
return lhs.current.ok == rhs.current.ok && (!lhs.current.ok || (
Q_ASSERT(lhs.tokenizer == rhs.tokenizer), lhs.current.state == rhs.current.state)); }
84#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
86 {
return !lhs.current.ok; }
90 {
return !rhs.current.ok; }
97 current = tokenizer->next(current.state);
112 template <bool = std::is_same<iterator, sentinel>::value>
113 [[nodiscard]]
constexpr sentinel end() const noexcept {
return {}; }
114 template <bool = std::is_same<iterator, sentinel>::value>
123#include <QtCore/qstringview.h>
130 template <
typename String>
142 template <
typename LHS,
typename RHS>
144 template <
typename Char,
typename...Args>
146#ifdef __cpp_lib_string_view
147 template <
typename Char,
typename...Args>
155 template <
typename String>
164 template <
typename String>
172 template <
typename Char,
typename...Args>
174 {
using type = std::basic_string<
Char, Args...>; };
177 template <
typename LHS,
typename RHS>
179 :
PinForImpl<typename QStringBuilder<LHS, RHS>::ConvertTo> {};
181 template <
typename StringLike>
189 template <typename T, bool pinned = is_owning_string_type<T>::value>
196 constexpr T
view(T
t)
const noexcept {
return t; }
200 template <
typename T>
206 constexpr Pinning(T &&
s) noexcept : m_string{std::move(
s)} {}
214 template <
typename T>
218 template <
typename Arg>
220 ->
decltype(this->
view(std::forward<Arg>(
a)))
221 {
return this->
view(std::forward<Arg>(
a)); }
224 template <
typename T>
228 template <
typename Arg>
230 ->
decltype(this->
view(std::forward<Arg>(
a)))
231 {
return this->
view(std::forward<Arg>(
a)); }
239 template <
typename Haystack,
typename Needle>
244template <
typename Haystack,
typename Needle>
253 template <
typename Container,
typename HPin>
254 struct if_haystack_not_pinned_impl : std::enable_if<std::is_empty<HPin>::value, bool> {};
255 template <
typename Container>
256 using if_haystack_not_pinned =
typename if_haystack_not_pinned_impl<Container, HPin>::type;
257 template <typename Container, typename Iterator = decltype(std::begin(std::declval<Container>()))>
258 using if_compatible_container =
typename std::enable_if<
261 typename std::iterator_traits<Iterator>::value_type
280 [[nodiscard]]
constexpr sentinel end() const noexcept {
return {}; }
281 [[nodiscard]]
constexpr sentinel cend() const noexcept {
return {}; }
287 noexcept(std::is_nothrow_copy_constructible<QStringTokenizer>::value)
292 :
HPin{
std::forward<Haystack>(haystack)},
293 NPin{
std::forward<Needle>(needle)},
302 noexcept(std::is_nothrow_copy_constructible<QStringTokenizer>::value)
303 :
HPin{
std::forward<Haystack>(haystack)},
304 NPin{
std::forward<Needle>(needle)},
310 template<
typename LContainer> LContainer
toContainer(LContainer &&
c = {})
const & {}
311 template<
typename RContainer> RContainer
toContainer(RContainer &&
c = {})
const && {}
313 template<
typename Container = QList<value_type>, if_compatible_container<Container> = true>
318 return std::forward<Container>(
c);
320 template<
typename Container = QList<value_type>, if_compatible_container<Container> = true,
321 if_haystack_not_pinned<Container> = true>
326 return std::forward<Container>(
c);
344#define Q_TOK_RESULT \
346 QtPrivate::Tok::PinFor<Haystack>, \
347 QtPrivate::Tok::PinFor<Needle> \
350template <
typename Haystack,
typename Needle>
352template <
typename Haystack,
typename Needle>
357#ifdef __cpp_deduction_guides
360template <
typename Haystack,
typename Needle>
363template <
typename Haystack,
typename Needle>
366template <
typename Haystack,
typename Needle>
369template <
typename Haystack,
typename Needle>
372template <
typename Haystack,
typename Needle>
379template <
typename Haystack,
typename Needle,
typename...Flags>
380[[nodiscard]]
constexpr auto
382 noexcept(
QtPrivate::Tok::is_nothrow_constructible_from<Haystack, Needle>::
value)
383 -> decltype(
QtPrivate::Tok::TokenizerResult<Haystack, Needle>{std::forward<Haystack>(
h),
384 std::forward<Needle>(
n),
flags...})
386 std::forward<Needle>(
n),
389template <
typename Haystack,
typename Needle>
395 return {{},
false,
state};
397 state.end = m_haystack.indexOf(m_needle,
state.start +
state.extra, m_cs);
399 if (
state.end >= 0) {
404 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
typename Base::const_iterator const_iterator
\typealias QStringTokenizer::value_type
Container toContainer(Container &&c={}) const &&
Container toContainer(Container &&c={}) const &
typename Base::pointer pointer
typename Base::difference_type difference_type
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
typename ViewForImpl< typename std::decay< String >::type >::type ViewFor
typename PinForImpl< typename std::remove_cv< StringLike >::type >::type PinFor
constexpr qsizetype size(QChar) noexcept
Q_TOK_RESULT TokenizerResult
std::is_nothrow_copy_constructible< TokenizerResult< Haystack, Needle > > is_nothrow_constructible_from
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