0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the tools applications of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
**
|
|
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.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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 |
|
|
100 |
QStringList failedResources() const { return m_failedResources; }
|
|
101 |
|
|
102 |
private:
|
|
103 |
struct Strings {
|
|
104 |
Strings();
|
|
105 |
const QString TAG_RCC;
|
|
106 |
const QString TAG_RESOURCE;
|
|
107 |
const QString TAG_FILE;
|
|
108 |
const QString ATTRIBUTE_LANG;
|
|
109 |
const QString ATTRIBUTE_PREFIX;
|
|
110 |
const QString ATTRIBUTE_ALIAS;
|
|
111 |
const QString ATTRIBUTE_THRESHOLD;
|
|
112 |
const QString ATTRIBUTE_COMPRESS;
|
|
113 |
};
|
|
114 |
friend class RCCFileInfo;
|
|
115 |
void reset();
|
|
116 |
bool addFile(const QString &alias, const RCCFileInfo &file);
|
|
117 |
bool interpretResourceFile(QIODevice *inputDevice, const QString &file,
|
|
118 |
QString currentPath = QString(), bool ignoreErrors = false);
|
|
119 |
bool writeHeader();
|
|
120 |
bool writeDataBlobs();
|
|
121 |
bool writeDataNames();
|
|
122 |
bool writeDataStructure();
|
|
123 |
bool writeInitializer();
|
|
124 |
void writeMangleNamespaceFunction(const QByteArray &name);
|
|
125 |
void writeAddNamespaceFunction(const QByteArray &name);
|
|
126 |
void writeHex(quint8 number);
|
|
127 |
void writeNumber2(quint16 number);
|
|
128 |
void writeNumber4(quint32 number);
|
|
129 |
void writeChar(char c) { m_out.append(c); }
|
|
130 |
void writeByteArray(const QByteArray &);
|
|
131 |
void write(const char *, int len);
|
|
132 |
|
|
133 |
const Strings m_strings;
|
|
134 |
RCCFileInfo *m_root;
|
|
135 |
QStringList m_fileNames;
|
|
136 |
QString m_resourceRoot;
|
|
137 |
QString m_initName;
|
|
138 |
Format m_format;
|
|
139 |
bool m_verbose;
|
|
140 |
int m_compressLevel;
|
|
141 |
int m_compressThreshold;
|
|
142 |
int m_treeOffset;
|
|
143 |
int m_namesOffset;
|
|
144 |
int m_dataOffset;
|
|
145 |
bool m_useNameSpace;
|
|
146 |
QStringList m_failedResources;
|
|
147 |
QIODevice *m_errorDevice;
|
|
148 |
QByteArray m_out;
|
|
149 |
};
|
|
150 |
|
|
151 |
QT_END_NAMESPACE
|
|
152 |
|
|
153 |
#endif // RCC_H
|