Changeset View
Changeset View
Standalone View
Standalone View
src/kconfig_compiler/KConfigParameters.cpp
- This file was added.
1 | /* This file is part of the KDE libraries | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) | ||||
3 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||||
4 | Copyright (c) 2003 Waldo Bastian <bastian@kde.org> | ||||
5 | Copyright (c) 2003 Zack Rusin <zack@kde.org> | ||||
6 | Copyright (c) 2006 Michaël Larouche <michael.larouche@kdemail.net> | ||||
7 | Copyright (c) 2008 Allen Winter <winter@kde.org> | ||||
8 | Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) | ||||
9 | | ||||
10 | This library is free software; you can redistribute it and/or | ||||
11 | modify it under the terms of the GNU Library General Public | ||||
12 | License as published by the Free Software Foundation; either | ||||
13 | version 2 of the License, or (at your option) any later version. | ||||
14 | | ||||
15 | This library is distributed in the hope that it will be useful, | ||||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
18 | Library General Public License for more details. | ||||
19 | | ||||
20 | You should have received a copy of the GNU Library General Public License | ||||
21 | along with this library; see the file COPYING.LIB. If not, write to | ||||
22 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
23 | Boston, MA 02110-1301, USA. | ||||
24 | */ | ||||
25 | | ||||
26 | #include "KConfigParameters.h" | ||||
27 | | ||||
28 | // TODO: Remove this. | ||||
29 | #undef QT_NO_CAST_FROM_ASCII | ||||
30 | | ||||
31 | #include <QDebug> | ||||
32 | #include <QFileInfo> | ||||
33 | | ||||
34 | namespace | ||||
35 | { | ||||
36 | QTextStream cout(stdout); | ||||
37 | QTextStream cerr(stderr); | ||||
38 | } | ||||
39 | | ||||
40 | KConfigParameters::KConfigParameters(const QString &codegenFilename) | ||||
41 | { | ||||
42 | if (!codegenFilename.endsWith(QLatin1String(".kcfgc"))) { | ||||
43 | cerr << "Codegen options file must have extension .kcfgc" << endl; | ||||
44 | exit(1); | ||||
45 | } | ||||
46 | | ||||
47 | baseName = QFileInfo(codegenFilename).fileName(); | ||||
48 | baseName = baseName.left(baseName.length() - 6); | ||||
49 | | ||||
50 | // Configure the compiler with some settings | ||||
51 | QSettings codegenConfig(codegenFilename, QSettings::IniFormat); | ||||
52 | | ||||
53 | nameSpace = codegenConfig.value(QStringLiteral("NameSpace")).toString(); | ||||
54 | className = codegenConfig.value(QStringLiteral("ClassName")).toString(); | ||||
55 | if (className.isEmpty()) { | ||||
56 | cerr << "Class name missing" << endl; | ||||
57 | exit(1); | ||||
58 | } | ||||
59 | inherits = codegenConfig.value(QStringLiteral("Inherits")).toString(); | ||||
60 | if (inherits.isEmpty()) { | ||||
61 | inherits = QStringLiteral("KConfigSkeleton"); | ||||
62 | } | ||||
63 | visibility = codegenConfig.value(QStringLiteral("Visibility")).toString(); | ||||
64 | if (!visibility.isEmpty()) { | ||||
65 | visibility += QLatin1Char(' '); | ||||
66 | } | ||||
67 | parentInConstructor = codegenConfig.value(QStringLiteral("ParentInConstructor"), false).toBool(); | ||||
68 | forceStringFilename = codegenConfig.value(QStringLiteral("ForceStringFilename"), false).toBool(); | ||||
69 | singleton = codegenConfig.value(QStringLiteral("Singleton"), false).toBool(); | ||||
70 | staticAccessors = singleton; | ||||
71 | customAddons = codegenConfig.value(QStringLiteral("CustomAdditions"), false).toBool(); | ||||
72 | memberVariables = codegenConfig.value(QStringLiteral("MemberVariables")).toString(); | ||||
73 | dpointer = (memberVariables == QLatin1String("dpointer")); | ||||
74 | headerIncludes = codegenConfig.value(QStringLiteral("IncludeFiles"), QStringList()).toStringList(); | ||||
75 | sourceIncludes = codegenConfig.value(QStringLiteral("SourceIncludeFiles"), QStringList()).toStringList(); | ||||
76 | mutators = codegenConfig.value(QStringLiteral("Mutators"), QStringList()).toStringList(); | ||||
77 | allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == QLatin1String("true"))); | ||||
78 | itemAccessors = codegenConfig.value(QStringLiteral("ItemAccessors"), false).toBool(); | ||||
79 | setUserTexts = codegenConfig.value(QStringLiteral("SetUserTexts"), false).toBool(); | ||||
80 | defaultGetters = codegenConfig.value(QStringLiteral("DefaultValueGetters"), QStringList()).toStringList(); | ||||
81 | allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == QLatin1String("true")); | ||||
82 | notifiers = codegenConfig.value(QStringLiteral("Notifiers"), QStringList()).toStringList(); | ||||
83 | allNotifiers = ((notifiers.count() == 1) && (notifiers.at(0).toLower() == QLatin1String("true"))); | ||||
84 | globalEnums = codegenConfig.value(QStringLiteral("GlobalEnums"), false).toBool(); | ||||
85 | useEnumTypes = codegenConfig.value(QStringLiteral("UseEnumTypes"), false).toBool(); | ||||
86 | const QString trString = codegenConfig.value(QStringLiteral("TranslationSystem")).toString().toLower(); | ||||
87 | generateProperties = codegenConfig.value(QStringLiteral("GenerateProperties"), false).toBool(); | ||||
88 | if (trString == QLatin1String("kde")) { | ||||
89 | translationSystem = KdeTranslation; | ||||
90 | translationDomain = codegenConfig.value(QStringLiteral("TranslationDomain")).toString(); | ||||
91 | } else { | ||||
92 | if (!trString.isEmpty() && trString != QLatin1String("qt")) { | ||||
93 | cerr << "Unknown translation system, falling back to Qt tr()" << endl; | ||||
94 | } | ||||
95 | translationSystem = QtTranslation; | ||||
96 | } | ||||
97 | qCategoryLoggingName = codegenConfig.value(QStringLiteral("CategoryLoggingName"), QString()).toString(); | ||||
98 | headerExtension = codegenConfig.value(QStringLiteral("HeaderExtension"), QStringLiteral("h")).toString(); | ||||
99 | sourceExtension = codegenConfig.value(QStringLiteral("SourceExtension"), QStringLiteral("cpp")).toString(); | ||||
100 | } |