summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qutf8stringview.h
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-10-29 18:05:25 +0100
committerTopi Reiniƶ <topi.reinio@qt.io>2020-11-06 21:03:51 +0000
commitb20779b192eb7cf0033fef7c7062ab36b7ec011a (patch)
treeff9ce3cccae6663b3e6fe03a2b55568d70976fca /src/corelib/text/qutf8stringview.h
parent604adc01c00bee770485308cbe0e2b2897b45fa7 (diff)
Doc: Add a workaround for QUtf8StringView's missing docs
QUtf8StringView is a specialization of QBasicUtf8StringView but we only want to document the former. Add a workaround when Q_CLANG_QDOC is defined to rename the base type, so the documentation in the .qdoc file is matched correctly. Fixes: QTBUG-88030 Task-number: QTBUG-86295 Change-Id: Id6e3d6fd5c28603bebf30771b7a47c3f76ca709d Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/corelib/text/qutf8stringview.h')
-rw-r--r--src/corelib/text/qutf8stringview.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/text/qutf8stringview.h b/src/corelib/text/qutf8stringview.h
index 55621588bd..8e0656660d 100644
--- a/src/corelib/text/qutf8stringview.h
+++ b/src/corelib/text/qutf8stringview.h
@@ -117,14 +117,22 @@ struct wrap_char { using type = char; };
} // namespace QtPrivate
+#ifdef Q_CLANG_QDOC
+#define QBasicUtf8StringView QUtf8StringView
+#else
template <bool UseChar8T>
+#endif
class QBasicUtf8StringView
{
public:
+#ifndef Q_CLANG_QDOC
using storage_type = typename std::conditional<UseChar8T,
QtPrivate::hide_char8_t,
QtPrivate::wrap_char
>::type::type;
+#else
+ using storage_type = typename QtPrivate::hide_char8_t;
+#endif
typedef const storage_type value_type;
typedef qptrdiff difference_type;
typedef qsizetype size_type;
@@ -226,7 +234,7 @@ public:
[[nodiscard]] constexpr qsizetype size() const noexcept { return m_size; }
[[nodiscard]] const_pointer data() const noexcept { return reinterpret_cast<const_pointer>(m_data); }
-#ifdef __cpp_char8_t
+#if defined(__cpp_char8_t) || defined(Q_CLANG_QDOC)
[[nodiscard]] const char8_t *utf8() const noexcept { return reinterpret_cast<const char8_t*>(m_data); }
#endif
@@ -344,6 +352,10 @@ private:
const storage_type *m_data;
qsizetype m_size;
};
+
+#ifdef Q_CLANG_QDOC
+#undef QBasicUtf8StringView
+#else
template <bool UseChar8T>
Q_DECLARE_TYPEINFO_BODY(QBasicUtf8StringView<UseChar8T>, Q_PRIMITIVE_TYPE);
@@ -354,6 +366,7 @@ QT_END_NO_CHAR8_T_NAMESPACE
QT_BEGIN_HAS_CHAR8_T_NAMESPACE
using QUtf8StringView = QBasicUtf8StringView<true>;
QT_END_HAS_CHAR8_T_NAMESPACE
+#endif // Q_CLANG_QDOC
template <typename QStringLike, std::enable_if_t<std::is_same_v<QStringLike, QByteArray>, bool> = true>
[[nodiscard]] inline q_no_char8_t::QUtf8StringView qToUtf8StringViewIgnoringNull(const QStringLike &s) noexcept