1// Copyright (C) 2017 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef REPCODEGENERATOR_H
5#define REPCODEGENERATOR_H
6
7#include "repparser.h"
8
9#include <QList>
10#include <QSet>
11#include <QString>
12#include <QTextStream>
13
14QT_BEGIN_NAMESPACE
15
16class QIODevice;
17
18class RepCodeGenerator
19{
20public:
21 enum Mode
22 {
23 REPLICA,
24 SOURCE,
25 SIMPLE_SOURCE,
26 MERGED
27 };
28
29 RepCodeGenerator(QIODevice *outputDevice, const AST &ast);
30
31 void generate(Mode mode, QString fileName);
32
33 QByteArray classSignature(const ASTClass &ac);
34private:
35 void generateHeader(Mode mode);
36 QString generateMetaTypeRegistration(const QSet<QString> &metaTypes);
37 QString generateMetaTypeRegistrationForPending(const QSet<QString> &metaTypes);
38
39 void generateSimpleSetter(const ASTProperty &property, bool generateOverride = true);
40 void generatePOD(const POD &pod);
41 void generateEnumGadget(const ASTEnum &en, const QString &className);
42 void generateDeclarationsForEnums(const QList<ASTEnum> &enums, bool generateQENUM=true);
43 QString formatQPropertyDeclarations(const POD &pod);
44 QString formatConstructors(const POD &pod);
45 QString formatPropertyGettersAndSetters(const POD &pod);
46 QString formatSignals(const POD &pod);
47 QString formatDataMembers(const POD &pod);
48 QString formatDebugOperator(const POD &pod);
49 QString formatMarshallingOperators(const POD &pod);
50 QString typeForMode(const ASTProperty &property, Mode mode);
51
52 void generateClass(Mode mode, const ASTClass &astClasses,
53 const QString &metaTypeRegistrationCode);
54 void generateSourceAPI(const ASTClass &astClass);
55
56private:
57 QTextStream m_stream;
58 AST m_ast;
59};
60
61QT_END_NAMESPACE
62
63#endif
64

source code of qtremoteobjects/tools/repc/repcodegenerator.h