diff --git a/src/plugins/qmldesigner/designercore/include/modelfwd.h b/src/plugins/qmldesigner/designercore/include/modelfwd.h index 59c5c467691..eedc46e3b56 100644 --- a/src/plugins/qmldesigner/designercore/include/modelfwd.h +++ b/src/plugins/qmldesigner/designercore/include/modelfwd.h @@ -7,11 +7,46 @@ #include "qmldesignercorelib_exports.h" #include +#include namespace QmlDesigner { using PropertyName = QByteArray; using PropertyNameView = QByteArrayView; using PropertyNameList = QList; + +template +class ByteArrayViewLiteral : public QByteArrayView +{ +public: + constexpr ByteArrayViewLiteral() noexcept + : QByteArrayView{Text, Size - 1} + {} + + const QByteArray &toByteArray() const noexcept + { + static auto b = QByteArray::fromRawData(Text, Size - 1); + + return b; + } + + operator const QByteArray &() const noexcept { return toByteArray(); } +}; + +#define MakeCppPropertyViewLiteral(name, text) \ + constexpr char name##InternalString[] = text; \ + constexpr ByteArrayViewLiteral name{}; \ + /* */ + +#define MakeHeaderPropertyViewLiteral(name, text) \ + inline constexpr char name##InternalString[] = text; \ + inline constexpr ByteArrayViewLiteral name{}; \ + /* */ + +#define MakeFunctionPropertyViewLiteral(name, text) \ + static constexpr char name##InternalString[] = text; \ + static constexpr ByteArrayViewLiteral name{}; \ + /* */ + using TypeName = QByteArray; using PropertyTypeList = QList; using IdName = QByteArray;