File: CppGenerator.h

package info (click to toggle)
bluez-qt 5.116.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,932 kB
  • sloc: cpp: 16,676; xml: 554; ansic: 337; sh: 13; makefile: 8
file content (51 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * BluezQt - Asynchronous BlueZ wrapper library
 *
 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
 */

#ifndef CPPGENERATOR_H
#define CPPGENERATOR_H

#include <QTextStream>

class BluezApiParser;
class Method;

class CppGenerator
{
public:
    struct Config {
        bool useOptional = false;
        bool useDeprecated = false;
        bool useExperimental = false;
        bool useLowercaseFileNames = false;
        QString author = QStringLiteral("John Doe <info@mail.com>");
        QString year = QStringLiteral("2019");
    };
    CppGenerator(const Config &config);

    bool generate(const BluezApiParser &parser);

protected:
    void writeAdaptorHeader(const BluezApiParser &parser);
    void writeAdaptorSource(const BluezApiParser &parser);

    static QString interfaceToClassName(const QString &interface);
    static QString lowerFirstChars(const QString &string);
    static void writeFooter(QTextStream &stream);
    static void writeInterface(QTextStream &stream, const QString &name);
    static void closeInterface(QTextStream &stream);
    static bool writeMethod(QTextStream &stream, const Method &method);
    static bool writeArg(QTextStream &stream, const QString &param, const QString &dir);
    static void writeAnnotation(QTextStream &stream, const QString &param, const QString &dir, int i);

    void writeCopyrightHeader(QTextStream &stream);

private:
    Config m_config;
};

#endif // CPPGENERATOR_H