1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLTRANSLATION_P_H
5#define QQMLTRANSLATION_P_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/qstring.h>
19
20#include <private/qv4qmlcontext_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class Q_QML_PRIVATE_EXPORT QQmlTranslation
25{
26public:
27 class Q_QML_PRIVATE_EXPORT QsTrData
28 {
29 QByteArray context;
30 QByteArray text;
31 QByteArray comment;
32 int number;
33
34 public:
35 QsTrData(const QString &fileNameForContext, const QString &text, const QString &comment,
36 int number);
37 QString translate() const;
38 QString serializeForQmltc() const;
39 QString idForQmlDebug() const;
40 };
41
42 class Q_QML_PRIVATE_EXPORT QsTrIdData
43 {
44 QByteArray id;
45 int number;
46
47 public:
48 QsTrIdData(const QString &id, int number);
49 QString translate() const;
50 QString serializeForQmltc() const;
51 QString idForQmlDebug() const;
52 };
53
54 // The static analyzer hates std::monostate in std::variant because
55 // that results in various uninitialized memory "problems". Just use
56 // std::nullptr_t to indicate "empty".
57 using Data = std::variant<std::nullptr_t, QsTrData, QsTrIdData>;
58
59private:
60 Data data;
61
62public:
63 QQmlTranslation(const Data &d);
64 QQmlTranslation();
65 QString translate() const;
66 QString serializeForQmltc() const;
67 QString idForQmlDebug() const;
68
69 static QString contextFromQmlFilename(const QString &qmlFilename);
70};
71
72QT_END_NAMESPACE
73
74#endif // QQMLTRANSLATION_P_H
75

source code of qtdeclarative/src/qml/common/qqmltranslation_p.h