File indexing completed on 2024-05-05 12:09:29
0001 /* 0002 * BluezQt - Asynchronous BlueZ wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef CPPGENERATOR_H 0010 #define CPPGENERATOR_H 0011 0012 #include <QTextStream> 0013 0014 class BluezApiParser; 0015 class Method; 0016 0017 class CppGenerator 0018 { 0019 public: 0020 struct Config { 0021 bool useOptional = false; 0022 bool useDeprecated = false; 0023 bool useExperimental = false; 0024 bool useLowercaseFileNames = false; 0025 QString author = QStringLiteral("John Doe <info@mail.com>"); 0026 QString year = QStringLiteral("2019"); 0027 }; 0028 CppGenerator(const Config &config); 0029 0030 bool generate(const BluezApiParser &parser); 0031 0032 protected: 0033 void writeAdaptorHeader(const BluezApiParser &parser); 0034 void writeAdaptorSource(const BluezApiParser &parser); 0035 0036 static QString interfaceToClassName(const QString &interface); 0037 static QString lowerFirstChars(const QString &string); 0038 static void writeFooter(QTextStream &stream); 0039 static void writeInterface(QTextStream &stream, const QString &name); 0040 static void closeInterface(QTextStream &stream); 0041 static bool writeMethod(QTextStream &stream, const Method &method); 0042 static bool writeArg(QTextStream &stream, const QString ¶m, const QString &dir); 0043 static void writeAnnotation(QTextStream &stream, const QString ¶m, const QString &dir, int i); 0044 0045 void writeCopyrightHeader(QTextStream &stream); 0046 0047 private: 0048 Config m_config; 0049 }; 0050 0051 #endif // CPPGENERATOR_H