3#ifndef QUTF8STRINGVIEW_H
4#define QUTF8STRINGVIEW_H
7#pragma qt_class(QUtf8StringView)
10#include <QtCore/qstringalgorithms.h>
11#include <QtCore/qstringfwd.h>
12#include <QtCore/qarraydata.h>
13#include <QtCore/qbytearrayview.h>
16#include <QtCore/q20type_traits.h>
21template <
typename Char>
24 std::is_same<Char, char8_t>,
26 std::is_same<Char, char>,
27 std::is_same<Char, uchar>,
28 std::is_same<Char, signed char>
30template <
typename Char>
34template <
typename Po
inter>
36template <
typename Char>
39template <
typename Po
inter>
43template <
typename T,
typename Enable =
void>
49 IsCompatiblePointer8<decltype(std::data(std::declval<const T &>()))>,
52 decltype(std::size(std::declval<const T &>())),
56 IsCompatibleChar8Type<typename std::iterator_traits<
57 decltype(std::begin(std::declval<const T &>()))>::value_type
60 decltype( std::begin(std::declval<const T &>()) != std::end(std::declval<const T &>()) ),
65 std::negation<std::is_same<std::decay_t<T>, QByteArray>>,
68 std::negation<std::is_same<std::decay_t<T>, QLatin1StringView>>,
71 std::negation<std::disjunction<
72 std::is_same<std::decay_t<T>, QBasicUtf8StringView<true>>,
73 std::is_same<std::decay_t<T>, QBasicUtf8StringView<false>>
75 >>> : std::true_type {};
88#define QBasicUtf8StringView QUtf8StringView
90template <
bool UseChar8T>
117 template <
typename Char>
118 using if_compatible_char = std::enable_if_t<QtPrivate::IsCompatibleChar8Type<Char>::value,
bool>;
120 template <
typename Po
inter>
121 using if_compatible_pointer = std::enable_if_t<QtPrivate::IsCompatiblePointer8<Pointer>::value,
bool>;
123 template <
typename T>
124 using if_compatible_qstring_like = std::enable_if_t<std::is_same_v<T, QByteArray>,
bool>;
126 template <
typename T>
127 using if_compatible_container = std::enable_if_t<QtPrivate::IsContainerCompatibleWithQUtf8StringView<T>::value,
bool>;
129 template <
typename Container>
130 static constexpr qsizetype lengthHelperContainer(
const Container &
c)
noexcept
137 template <
typename Char,
size_t N>
138 static constexpr qsizetype lengthHelperContainer(
const Char (&
str)[N])
noexcept
140 const auto it = std::char_traits<Char>::find(
str, N,
Char(0));
145 template <
typename Char>
153 : m_data(
nullptr), m_size(0) {}
157 template <
typename Char, if_compatible_
char<Char> = true>
159 : m_data(castHelper(
str)),
162 template <
typename Char, if_compatible_
char<Char> = true>
167 template <
typename Char,
size_t N>
170 template <
typename Char>
173 template <
typename Po
inter, if_compatible_po
inter<Po
inter> = true>
176 str ? std::char_traits<std::remove_cv_t<std::remove_pointer_t<Pointer>>>
::length(
str) : 0) {}
183 template <
typename String, if_compatible_q
string_like<String> = true>
188 template <
typename Container, if_compatible_container<Container> = true>
192#if defined(__cpp_char8_t) && !defined(Q_QDOC)
197 template <
typename Char,
size_t Size, if_compatible_
char<Char> = true>
206 [[nodiscard]]
const char8_t *utf8() const noexcept {
return reinterpret_cast<const char8_t*
>(m_data); }
228 if (
size_t(
n) >=
size_t(
size()))
235 if (
size_t(
n) >=
size_t(
size()))
252 { verify(
n); m_size =
n; }
254 { verify(
n); m_size -=
n; }
273 [[nodiscard]]
constexpr bool empty() const noexcept {
return size() == 0; }
280 [[nodiscard]]
constexpr bool isNull() const noexcept {
return !m_data; }
281 [[nodiscard]]
constexpr bool isEmpty() const noexcept {
return empty(); }
305 return lhs.size() == rhs.size()
312#ifdef __cpp_impl_three_way_comparison
338#undef QBasicUtf8StringView
340template <
bool UseChar8T>
343template <
typename QStringLike, std::enable_if_t<std::is_same_v<QStringLike, QByteArray>,
bool> = true>
345{
return q_no_char8_t::QUtf8StringView(
s.data(),
s.size()); }
constexpr QBasicUtf8StringView mid(qsizetype pos, qsizetype n=-1) const
const_reverse_iterator crend() const noexcept
constexpr QBasicUtf8StringView first(qsizetype n) const
constexpr bool empty() const noexcept
constexpr bool isNull() const noexcept
int compare(QBasicUtf8StringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr void truncate(qsizetype n)
value_type & const_reference
constexpr QBasicUtf8StringView(const Char *f, const Char *l)
constexpr QBasicUtf8StringView(const Container &c) noexcept
constexpr QBasicUtf8StringView(const Pointer &str) noexcept
constexpr qsizetype size() const noexcept
constexpr QBasicUtf8StringView(const Char *str, qsizetype len)
const_pointer data() const noexcept
const_reverse_iterator rbegin() const noexcept
constexpr QBasicUtf8StringView sliced(qsizetype pos) const
constexpr qsizetype length() const noexcept
constexpr bool isEmpty() const noexcept
friend bool operator<(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
bool isValidUtf8() const noexcept
const_iterator begin() const noexcept
static constexpr QBasicUtf8StringView fromArray(const Char(&string)[Size]) noexcept
friend bool operator<=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
constexpr storage_type operator[](qsizetype n) const
friend bool operator>(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
friend bool operator==(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
const_iterator cend() const noexcept
constexpr storage_type back() const
constexpr QBasicUtf8StringView sliced(qsizetype pos, qsizetype n) const
QBasicUtf8StringView(const String &str) noexcept
const_reverse_iterator rend() const noexcept
std::reverse_iterator< iterator > reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
value_type * const_pointer
const_pointer const_iterator
constexpr QBasicUtf8StringView last(qsizetype n) const
constexpr QBasicUtf8StringView(std::nullptr_t) noexcept
constexpr storage_type at(qsizetype n) const
const storage_type value_type
typename std::conditional< UseChar8T, QtPrivate::hide_char8_t, QtPrivate::wrap_char >::type::type storage_type
constexpr storage_type front() const
constexpr QBasicUtf8StringView left(qsizetype n) const
friend bool operator!=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
friend bool operator>=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
constexpr QBasicUtf8StringView() noexcept
const_iterator end() const noexcept
constexpr void chop(qsizetype n)
const_reverse_iterator crbegin() const noexcept
const_iterator cbegin() const noexcept
constexpr QBasicUtf8StringView right(qsizetype n) const
constexpr QBasicUtf8StringView chopped(qsizetype n) const
bool isValidUtf8() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
IsCompatibleChar8TypeHelper< q20::remove_cvref_t< Char > > IsCompatibleChar8Type
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
std::disjunction< std::is_same< Char, char >, std::is_same< Char, uchar >, std::is_same< Char, signed char > > IsCompatibleChar8TypeHelper
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
q_no_char8_t::QUtf8StringView qToUtf8StringViewIgnoringNull(const QStringLike &s) noexcept