1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef TEMPLATEPARSER_H
6#define TEMPLATEPARSER_H
7
8#include <QObject>
9#include <QVector>
10#include <QMap>
11
12namespace templateMgr {
13
14struct TemplateDetail{
15 QString name;
16 QString path;
17 bool leafNode;
18};
19
20struct TemplateCategory {
21 QString type;
22 QVector<TemplateDetail> templateVec;
23};
24
25struct Template {
26 QString category;
27 QVector<TemplateCategory> templateVec;
28};
29
30using TemplateVector = QVector<Template>;
31
32
33struct EditItem {
34 QString key;
35 QString displayName;
36 QString type;
37 QStringList defaultValues;
38 bool browse;
39};
40
41struct FileOperator {
42 QString sourceFile;
43 QStringList replaceKeys;
44};
45
46struct FileGenerator {
47 QString rootFolder;
48 QString destPath;
49 QString templateFile;
50 QString newfileName;
51 QVector<FileOperator> operations;
52};
53
54struct WizardInfo {
55 QString type;
56 QString kit;
57 QString language;
58 QString trDisplayName;
59 QString trDescription;
60 QVector<EditItem> configures;
61 FileGenerator generator;
62};
63
64class TemplateParser : public QObject
65{
66 Q_OBJECT
67public:
68 static bool readTemplateConfig(TemplateVector &templateVec);
69 static bool readWizardConfig(const QString &projectPath, WizardInfo &wizardInfo);
70
71signals:
72
73private slots:
74
75private:
76 explicit TemplateParser(QObject *parent = nullptr);
77 ~TemplateParser();
78
79};
80
81} //namespace templateMgr
82
83Q_DECLARE_METATYPE(templateMgr::TemplateDetail)
84
85#endif // TEMPLATEPARSER_H
86