| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef QQMLJSVALUETYPEFROMSTRINGCHECK_H |
| 5 | #define QQMLJSVALUETYPEFROMSTRINGCHECK_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qglobal.h> |
| 19 | #include <QtCore/qstring.h> |
| 20 | |
| 21 | #include <qtqmlcompilerexports.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | struct Q_QMLCOMPILER_EXPORT QQmlJSStructuredTypeError |
| 26 | { |
| 27 | QString code; |
| 28 | bool constructedFromInvalidString = false; |
| 29 | |
| 30 | bool isValid() const { return !code.isEmpty() || constructedFromInvalidString; } |
| 31 | static QQmlJSStructuredTypeError withInvalidString() { return { .code: QString(), .constructedFromInvalidString: true }; } |
| 32 | static QQmlJSStructuredTypeError withValidString() { return { .code: QString(), .constructedFromInvalidString: false }; } |
| 33 | static QQmlJSStructuredTypeError fromSuggestedString(const QString &enhancedString) |
| 34 | { |
| 35 | return { .code: enhancedString, .constructedFromInvalidString: false }; |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | class Q_QMLCOMPILER_EXPORT QQmlJSValueTypeFromStringCheck |
| 41 | { |
| 42 | public: |
| 43 | static QQmlJSStructuredTypeError hasError(const QString &typeName, const QString &value); |
| 44 | }; |
| 45 | |
| 46 | QT_END_NAMESPACE |
| 47 | |
| 48 | #endif // QQMLJSVALUETYPEFROMSTRINGCHECK_H |
| 49 | |