Mercurial > projects > qtd
annotate tools/drcc/rcc.h @ 396:d0a103f25091
Work around CTFE regression in DMD.
The error message emitted by DMD 2.051 was ?Declaration (string, ?, string) allSymbols = tuple("__ctor", ?, "__T8Q_OBJECTZ") is not yet implemented in CTFE?.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Mon, 03 Jan 2011 08:06:13 +0100 |
parents | a2871e6b8b15 |
children |
rev | line source |
---|---|
57 | 1 /**************************************************************************** |
2 ** | |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | |
4 ** Contact: Qt Software Information (qt-info@nokia.com) | |
5 ** | |
6 ** This file is part of the tools applications of the Qt Toolkit. | |
7 ** | |
8 ** $QT_BEGIN_LICENSE:LGPL$ | |
9 ** Commercial Usage | |
10 ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 ** accordance with the Qt Commercial License Agreement provided with the | |
12 ** Software or, alternatively, in accordance with the terms contained in | |
13 ** a written agreement between you and Nokia. | |
14 ** | |
15 ** GNU Lesser General Public License Usage | |
16 ** Alternatively, this file may be used under the terms of the GNU Lesser | |
17 ** General Public License version 2.1 as published by the Free Software | |
18 ** Foundation and appearing in the file LICENSE.LGPL included in the | |
19 ** packaging of this file. Please review the following information to | |
20 ** ensure the GNU Lesser General Public License version 2.1 requirements | |
21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |
22 ** | |
23 ** In addition, as a special exception, Nokia gives you certain | |
24 ** additional rights. These rights are described in the Nokia Qt LGPL | |
25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | |
26 ** package. | |
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 ** | |
36 ** If you are unsure which license is appropriate for your use, please | |
37 ** contact the sales department at qt-sales@nokia.com. | |
38 ** $QT_END_LICENSE$ | |
39 ** | |
40 ****************************************************************************/ | |
41 | |
42 #ifndef RCC_H | |
43 #define RCC_H | |
44 | |
45 #include <QtCore/QStringList> | |
46 #include <QtCore/QHash> | |
47 #include <QtCore/QString> | |
48 | |
49 QT_BEGIN_NAMESPACE | |
50 | |
51 class RCCFileInfo; | |
52 class QIODevice; | |
53 class QTextStream; | |
54 | |
55 | |
56 class RCCResourceLibrary | |
57 { | |
58 RCCResourceLibrary(const RCCResourceLibrary &); | |
59 RCCResourceLibrary &operator=(const RCCResourceLibrary &); | |
60 | |
61 public: | |
62 RCCResourceLibrary(); | |
63 ~RCCResourceLibrary(); | |
64 | |
65 bool output(QIODevice &out, QIODevice &errorDevice); | |
66 | |
67 bool readFiles(bool ignoreErrors, QIODevice &errorDevice); | |
68 | |
69 enum Format { Binary, C_Code }; | |
70 void setFormat(Format f) { m_format = f; } | |
71 Format format() const { return m_format; } | |
72 | |
73 void setInputFiles(const QStringList &files) { m_fileNames = files; } | |
74 QStringList inputFiles() const { return m_fileNames; } | |
75 | |
76 QStringList dataFiles() const; | |
77 | |
78 // Return a map of resource identifier (':/newPrefix/images/p1.png') to file. | |
79 typedef QHash<QString, QString> ResourceDataFileMap; | |
80 ResourceDataFileMap resourceDataFileMap() const; | |
81 | |
82 void setVerbose(bool b) { m_verbose = b; } | |
83 bool verbose() const { return m_verbose; } | |
84 | |
85 void setInitName(const QString &name) { m_initName = name; } | |
86 QString initName() const { return m_initName; } | |
87 | |
88 void setCompressLevel(int c) { m_compressLevel = c; } | |
89 int compressLevel() const { return m_compressLevel; } | |
90 | |
91 void setCompressThreshold(int t) { m_compressThreshold = t; } | |
92 int compressThreshold() const { return m_compressThreshold; } | |
93 | |
94 void setResourceRoot(const QString &root) { m_resourceRoot = root; } | |
95 QString resourceRoot() const { return m_resourceRoot; } | |
96 | |
97 void setUseNameSpace(bool v) { m_useNameSpace = v; } | |
98 bool useNameSpace() const { return m_useNameSpace; } | |
99 | |
61
a2871e6b8b15
drcc: automatic initialization of resources with program start (disabled with option -no-static-initialize)
SokoL_SD
parents:
57
diff
changeset
|
100 void setStaticInitialize(bool v) { m_staticInitialize = v; } |
a2871e6b8b15
drcc: automatic initialization of resources with program start (disabled with option -no-static-initialize)
SokoL_SD
parents:
57
diff
changeset
|
101 bool staticInitialize() const { return m_staticInitialize; } |
a2871e6b8b15
drcc: automatic initialization of resources with program start (disabled with option -no-static-initialize)
SokoL_SD
parents:
57
diff
changeset
|
102 |
57 | 103 QStringList failedResources() const { return m_failedResources; } |
104 | |
105 private: | |
106 struct Strings { | |
107 Strings(); | |
108 const QString TAG_RCC; | |
109 const QString TAG_RESOURCE; | |
110 const QString TAG_FILE; | |
111 const QString ATTRIBUTE_LANG; | |
112 const QString ATTRIBUTE_PREFIX; | |
113 const QString ATTRIBUTE_ALIAS; | |
114 const QString ATTRIBUTE_THRESHOLD; | |
115 const QString ATTRIBUTE_COMPRESS; | |
116 }; | |
117 friend class RCCFileInfo; | |
118 void reset(); | |
119 bool addFile(const QString &alias, const RCCFileInfo &file); | |
120 bool interpretResourceFile(QIODevice *inputDevice, const QString &file, | |
121 QString currentPath = QString(), bool ignoreErrors = false); | |
122 bool writeHeader(); | |
123 bool writeDataBlobs(); | |
124 bool writeDataNames(); | |
125 bool writeDataStructure(); | |
126 bool writeInitializer(); | |
127 void writeMangleNamespaceFunction(const QByteArray &name); | |
128 void writeAddNamespaceFunction(const QByteArray &name); | |
129 void writeHex(quint8 number); | |
130 void writeNumber2(quint16 number); | |
131 void writeNumber4(quint32 number); | |
132 void writeChar(char c) { m_out.append(c); } | |
133 void writeByteArray(const QByteArray &); | |
134 void write(const char *, int len); | |
135 | |
136 const Strings m_strings; | |
137 RCCFileInfo *m_root; | |
138 QStringList m_fileNames; | |
139 QString m_resourceRoot; | |
140 QString m_initName; | |
141 Format m_format; | |
142 bool m_verbose; | |
143 int m_compressLevel; | |
144 int m_compressThreshold; | |
145 int m_treeOffset; | |
146 int m_namesOffset; | |
147 int m_dataOffset; | |
148 bool m_useNameSpace; | |
61
a2871e6b8b15
drcc: automatic initialization of resources with program start (disabled with option -no-static-initialize)
SokoL_SD
parents:
57
diff
changeset
|
149 bool m_staticInitialize; |
57 | 150 QStringList m_failedResources; |
151 QIODevice *m_errorDevice; | |
152 QByteArray m_out; | |
153 }; | |
154 | |
155 QT_END_NAMESPACE | |
156 | |
157 #endif // RCC_H |