1// Copyright (C) 2020 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 QQMLJSSTREAMWRITER_P_H
5#define QQMLJSSTREAMWRITER_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#include <QtCore/QIODevice>
18#include <QtCore/QList>
19#include <QtCore/QString>
20#include <QtCore/QScopedPointer>
21#include <QtCore/QPair>
22
23QT_BEGIN_NAMESPACE
24
25class QQmlJSStreamWriter
26{
27public:
28 QQmlJSStreamWriter(QByteArray *array);
29
30 void writeStartDocument();
31 void writeEndDocument();
32 void writeLibraryImport(const QString &uri, int majorVersion, int minorVersion, const QString &as = QString());
33 //void writeFilesystemImport(const QString &file, const QString &as = QString());
34 void writeStartObject(const QString &component);
35 void writeEndObject();
36 void writeScriptBinding(const QString &name, const QString &rhs);
37 void writeScriptObjectLiteralBinding(const QString &name, const QList<QPair<QString, QString> > &keyValue);
38 void writeArrayBinding(const QString &name, const QStringList &elements);
39 void write(const QString &data);
40 void writeBooleanBinding(const QString &name, bool value);
41
42private:
43 void writeIndent();
44 void writePotentialLine(const QByteArray &line);
45 void flushPotentialLinesWithNewlines();
46
47 int m_indentDepth;
48 QList<QByteArray> m_pendingLines;
49 int m_pendingLineLength;
50 bool m_maybeOneline;
51 QScopedPointer<QIODevice> m_stream;
52};
53
54QT_END_NAMESPACE
55
56#endif // QQMLJSSTREAMWRITER_P_H
57

source code of qtdeclarative/src/qmltyperegistrar/qqmljsstreamwriter_p.h