File indexing completed on 2024-05-12 03:54:30

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org>
0005     SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
0006     SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org>
0007     SPDX-FileCopyrightText: 2006 Michaƫl Larouche <michael.larouche@kdemail.net>
0008     SPDX-FileCopyrightText: 2008 Allen Winter <winter@kde.org>
0009     SPDX-FileCopyrightText: 2020 Tomaz Cananbrava <tcanabrava@kde.org>
0010 
0011     SPDX-License-Identifier: LGPL-2.0-or-later
0012 */
0013 
0014 #ifndef KCONFIGSOURCEGENERATOR_H
0015 #define KCONFIGSOURCEGENERATOR_H
0016 
0017 #include "KConfigCodeGeneratorBase.h"
0018 #include "KConfigCommonStructs.h"
0019 
0020 #include <QList>
0021 #include <QString>
0022 
0023 class KConfigParameters;
0024 class CfgEntry;
0025 class QTextStream;
0026 struct ParseResult;
0027 
0028 class KConfigSourceGenerator : public KConfigCodeGeneratorBase
0029 {
0030 public:
0031     KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &parameters, ParseResult &parseResult);
0032 
0033     void start() override;
0034 
0035 private:
0036     // Those are fairly self contained functions.
0037     void createHeaders();
0038     void createPrivateDPointerImplementation();
0039     void createSingletonImplementation();
0040     void createPreamble();
0041     void createDestructor();
0042     void createConstructorParameterList();
0043     void createParentConstructorCall();
0044     void createInitializerList();
0045     void createDefaultValueGetterSetter();
0046     void createNonModifyingSignalsHelper();
0047     void createSignalFlagsHandler();
0048     void includeMoc();
0049 
0050     // Constructor related methods
0051     // the `do` methods have related helper functions that are only related
0052     // to it. So we can break the function into many smaller ones and create
0053     // logic inside of the `do` function.
0054     void doConstructor();
0055     void createEnums(const CfgEntry *entry);
0056     void createNormalEntry(const CfgEntry *entry, const QString &key);
0057     void createIndexedEntry(const CfgEntry *entry, const QString &key);
0058     void handleCurrentGroupChange(const CfgEntry *entry);
0059 
0060     void doGetterSetterDPointerMode();
0061     void createGetterDPointerMode(const CfgEntry *entry);
0062     void createImmutableGetterDPointerMode(const CfgEntry *entry);
0063     void createSetterDPointerMode(const CfgEntry *entry);
0064     void createItemGetterDPointerMode(const CfgEntry *entry);
0065 
0066 private:
0067     QString mCurrentGroup;
0068     QStringList mConfigGroupList; // keeps track of generated KConfigGroup;
0069 };
0070 
0071 #endif