File indexing completed on 2024-05-19 15:46:02

0001 /*
0002     SPDX-FileCopyrightText: 2019 Daniel Mensinger <daniel@mensinger-ka.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "mesonactionbase.h"
0010 
0011 #include <QJsonObject>
0012 
0013 class MesonKWARGSInfo;
0014 class MesonKWARGSProjectInfo;
0015 class MesonKWARGSTargetInfo;
0016 class MesonKWARGSDependencyInfo;
0017 
0018 using MesonKWARGSInfoPtr = std::shared_ptr<MesonKWARGSInfo>;
0019 using MesonKWARGSProjectInfoPtr = std::shared_ptr<MesonKWARGSProjectInfo>;
0020 using MesonKWARGSTargetInfoPtr = std::shared_ptr<MesonKWARGSTargetInfo>;
0021 using MesonKWARGSDependencyInfoPtr = std::shared_ptr<MesonKWARGSDependencyInfo>;
0022 
0023 class MesonKWARGSInfo : public MesonRewriterActionBase
0024 {
0025 public:
0026     enum Function { PROJECT, TARGET, DEPENDENCY };
0027 
0028 public:
0029     explicit MesonKWARGSInfo(Function fn, const QString& id);
0030     virtual ~MesonKWARGSInfo();
0031 
0032     QJsonObject command() override;
0033     void parseResult(QJsonObject data) override;
0034 
0035     Function function() const;
0036     QString id() const;
0037 
0038     bool hasKWARG(const QString& kwarg) const;
0039     QJsonValue get(const QString& kwarg) const;
0040     QString getString(const QString& kwarg) const;
0041     QStringList getArray(const QString& kwarg) const;
0042 
0043 private:
0044     Function m_func;
0045     QString m_id;
0046     QJsonObject m_result;
0047 
0048     QString m_infoID;
0049 };
0050 
0051 class MesonKWARGSProjectInfo : public MesonKWARGSInfo
0052 {
0053 public:
0054     explicit MesonKWARGSProjectInfo();
0055     virtual ~MesonKWARGSProjectInfo();
0056 };
0057 
0058 class MesonKWARGSTargetInfo : public MesonKWARGSInfo
0059 {
0060 public:
0061     explicit MesonKWARGSTargetInfo(const QString& id);
0062     virtual ~MesonKWARGSTargetInfo();
0063 };
0064 
0065 class MesonKWARGSDependencyInfo : public MesonKWARGSInfo
0066 {
0067 public:
0068     explicit MesonKWARGSDependencyInfo(const QString& id);
0069     virtual ~MesonKWARGSDependencyInfo();
0070 };