5#ifndef STRINGLITERALS_H
6#define STRINGLITERALS_H
10#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
11using namespace Qt::Literals::StringLiterals;
12#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
13inline QString
operator"" _s(
const char16_t *str,
size_t size)
noexcept
15 return QString(QStringPrivate(
nullptr,
const_cast<char16_t *
>(str), qsizetype(size)));
18constexpr inline QLatin1String
operator"" _L1(
const char *str,
size_t size)
noexcept
20 return QLatin1String { str, int(size) };
23namespace QXmpp::Private {
25template<std::
size_t N>
26struct StringLiteralData {
30 constexpr StringLiteralData(
const char16_t (&str)[N])
32 std::ranges::copy(str, data);
36template<std::
size_t N>
37struct StaticStringData {
38 QArrayData str = Q_STATIC_STRING_DATA_HEADER_INITIALIZER(N - 1);
41 StaticStringData(
const char16_t (&str)[N])
43 std::ranges::copy(str, data);
46 QStringData *data_ptr()
const
48 return const_cast<QStringData *
>(
static_cast<const QStringData *
>(&str));
54template<QXmpp::Private::StringLiteralData str>
57 static const auto staticData = QXmpp::Private::StaticStringData<str.size>(str.data);
58 return QString(QStringDataPtr { staticData.data_ptr() });
61constexpr inline QLatin1String
operator"" _L1(
const char *str,
size_t size)
noexcept
63 return QLatin1String { str, int(size) };