Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:38

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // Copyright (C) 2020 Intel Corporation.
0003 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0004 
0005 #ifndef QSTRINGLITERAL_H
0006 #define QSTRINGLITERAL_H
0007 
0008 #include <QtCore/qarraydata.h>
0009 #include <QtCore/qarraydatapointer.h>
0010 
0011 #if 0
0012 #pragma qt_class(QStringLiteral)
0013 #endif
0014 
0015 QT_BEGIN_NAMESPACE
0016 
0017 // all our supported compilers support Unicode string literals,
0018 // even if their Q_COMPILER_UNICODE_STRING has been revoked due
0019 // to lacking stdlib support. But QStringLiteral only needs the
0020 // core language feature, so just use u"" here unconditionally:
0021 
0022 #define QT_UNICODE_LITERAL(str) u"" str
0023 
0024 using QStringPrivate = QArrayDataPointer<char16_t>;
0025 
0026 namespace QtPrivate {
0027 template <qsizetype N>
0028 static Q_ALWAYS_INLINE QStringPrivate qMakeStringPrivate(const char16_t (&literal)[N])
0029 {
0030     // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
0031     auto str = const_cast<char16_t *>(literal);
0032     return { nullptr, str, N - 1 };
0033 }
0034 }
0035 
0036 #define QStringLiteral(str) \
0037     (QString(QtPrivate::qMakeStringPrivate(QT_UNICODE_LITERAL(str)))) \
0038     /**/
0039 
0040 
0041 QT_END_NAMESPACE
0042 
0043 #endif // QSTRINGLITERAL_H