[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | /*
|
---|
| 43 | config.h
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | #ifndef CONFIG_H
|
---|
| 47 | #define CONFIG_H
|
---|
| 48 |
|
---|
| 49 | #include <QMap>
|
---|
| 50 | #include <QSet>
|
---|
| 51 | #include <QStringList>
|
---|
| 52 |
|
---|
| 53 | #include "location.h"
|
---|
| 54 |
|
---|
| 55 | QT_BEGIN_NAMESPACE
|
---|
| 56 |
|
---|
| 57 | class Config
|
---|
| 58 | {
|
---|
| 59 | public:
|
---|
| 60 | Config(const QString& programName);
|
---|
| 61 | ~Config();
|
---|
| 62 |
|
---|
| 63 | void load(const QString& fileName);
|
---|
| 64 | void setStringList(const QString& var, const QStringList& values);
|
---|
| 65 |
|
---|
| 66 | const QString& programName() const { return prog; }
|
---|
| 67 | const Location& location() const { return loc; }
|
---|
| 68 | const Location& lastLocation() const { return lastLoc; }
|
---|
| 69 | bool getBool(const QString& var) const;
|
---|
| 70 | int getInt(const QString& var) const;
|
---|
| 71 | QString getString(const QString& var) const;
|
---|
| 72 | QSet<QString> getStringSet(const QString& var) const;
|
---|
| 73 | QStringList getStringList(const QString& var) const;
|
---|
| 74 | QRegExp getRegExp(const QString& var) const;
|
---|
| 75 | QList<QRegExp> getRegExpList(const QString& var) const;
|
---|
| 76 | QSet<QString> subVars(const QString& var) const;
|
---|
| 77 | QStringList getAllFiles(const QString& filesVar,
|
---|
| 78 | const QString& dirsVar,
|
---|
| 79 | const QString& defaultNameFilter,
|
---|
| 80 | const QSet<QString> &excludedDirs = QSet<QString>());
|
---|
| 81 |
|
---|
| 82 | static QStringList getFilesHere(const QString& dir,
|
---|
| 83 | const QString& nameFilter,
|
---|
| 84 | const QSet<QString> &excludedDirs = QSet<QString>());
|
---|
| 85 | static QString findFile(const Location& location,
|
---|
| 86 | const QStringList &files,
|
---|
| 87 | const QStringList& dirs,
|
---|
| 88 | const QString& fileName,
|
---|
| 89 | QString& userFriendlyFilePath);
|
---|
| 90 | static QString findFile(const Location &location,
|
---|
| 91 | const QStringList &files,
|
---|
| 92 | const QStringList &dirs,
|
---|
| 93 | const QString &fileBase,
|
---|
| 94 | const QStringList &fileExtensions,
|
---|
| 95 | QString &userFriendlyFilePath);
|
---|
| 96 | static QString copyFile(const Location& location,
|
---|
| 97 | const QString& sourceFilePath,
|
---|
| 98 | const QString& userFriendlySourceFilePath,
|
---|
| 99 | const QString& targetDirPath);
|
---|
| 100 | static int numParams(const QString& value);
|
---|
| 101 | static bool removeDirContents(const QString& dir);
|
---|
| 102 |
|
---|
| 103 | QT_STATIC_CONST QString dot;
|
---|
| 104 |
|
---|
| 105 | private:
|
---|
| 106 | static bool isMetaKeyChar(QChar ch);
|
---|
| 107 | void load(Location location, const QString& fileName);
|
---|
| 108 |
|
---|
| 109 | QString prog;
|
---|
| 110 | Location loc;
|
---|
| 111 | Location lastLoc;
|
---|
| 112 | QMap<QString, Location> locMap;
|
---|
| 113 | QMap<QString, QStringList> stringListValueMap;
|
---|
| 114 | QMap<QString, QString> stringValueMap;
|
---|
| 115 |
|
---|
| 116 | static QMap<QString, QString> uncompressedFiles;
|
---|
| 117 | static QMap<QString, QString> extractedDirs;
|
---|
| 118 | static int numInstances;
|
---|
| 119 | };
|
---|
| 120 |
|
---|
| 121 | #define CONFIG_ALIAS "alias"
|
---|
[846] | 122 | #define CONFIG_APPLICATION "application"
|
---|
[2] | 123 | #define CONFIG_BASE "base" // ### don't document for now
|
---|
| 124 | #define CONFIG_CODEINDENT "codeindent"
|
---|
| 125 | #define CONFIG_DEFINES "defines"
|
---|
| 126 | #define CONFIG_DESCRIPTION "description"
|
---|
| 127 | #define CONFIG_EDITION "edition"
|
---|
| 128 | #define CONFIG_EXAMPLEDIRS "exampledirs"
|
---|
| 129 | #define CONFIG_EXAMPLES "examples"
|
---|
| 130 | #define CONFIG_EXCLUDEDIRS "excludedirs"
|
---|
| 131 | #define CONFIG_EXTRAIMAGES "extraimages"
|
---|
| 132 | #define CONFIG_FALSEHOODS "falsehoods"
|
---|
| 133 | #define CONFIG_FORMATTING "formatting"
|
---|
| 134 | #define CONFIG_GENERATEINDEX "generateindex"
|
---|
| 135 | #define CONFIG_HEADERDIRS "headerdirs"
|
---|
| 136 | #define CONFIG_HEADERS "headers"
|
---|
| 137 | #define CONFIG_IGNOREDIRECTIVES "ignoredirectives"
|
---|
| 138 | #define CONFIG_IGNORETOKENS "ignoretokens"
|
---|
| 139 | #define CONFIG_IMAGEDIRS "imagedirs"
|
---|
| 140 | #define CONFIG_IMAGES "images"
|
---|
| 141 | #define CONFIG_INDEXES "indexes"
|
---|
| 142 | #define CONFIG_LANGUAGE "language"
|
---|
| 143 | #define CONFIG_MACRO "macro"
|
---|
[846] | 144 | #define CONFIG_NATURALLANGUAGE "naturallanguage"
|
---|
|
---|