OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / share / qtcreator / qml / qmldump / qmlstreamwriter.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 // WARNING: This code is shared with the qmlplugindump tool code in Qt.
34 //          Modifications to this file need to be applied there.
35
36 #ifndef QMLSTREAMWRITER_H
37 #define QMLSTREAMWRITER_H
38
39 #include <QtCore/QIODevice>
40 #include <QtCore/QList>
41 #include <QtCore/QString>
42 #include <QtCore/QScopedPointer>
43 #include <QtCore/QPair>
44
45 class QmlStreamWriter
46 {
47 public:
48     QmlStreamWriter(QByteArray *array);
49
50     void writeStartDocument();
51     void writeEndDocument();
52     void writeLibraryImport(const QString &uri, int majorVersion, int minorVersion, const QString &as = QString());
53     //void writeFilesystemImport(const QString &file, const QString &as = QString());
54     void writeStartObject(const QString &component);
55     void writeEndObject();
56     void writeScriptBinding(const QString &name, const QString &rhs);
57     void writeScriptObjectLiteralBinding(const QString &name, const QList<QPair<QString, QString> > &keyValue);
58     void writeArrayBinding(const QString &name, const QStringList &elements);
59     void write(const QString &data);
60
61 private:
62     void writeIndent();
63     void writePotentialLine(const QByteArray &line);
64     void flushPotentialLinesWithNewlines();
65
66     int m_indentDepth;
67     QList<QByteArray> m_pendingLines;
68     int m_pendingLineLength;
69     bool m_maybeOneline;
70     QScopedPointer<QIODevice> m_stream;
71 };
72
73 #endif // QMLSTREAMWRITER_H