source: trunk/src/tools/rcc/rcc.h@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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**
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** 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
49QT_BEGIN_NAMESPACE
50
51class RCCFileInfo;
52class QIODevice;
53class QTextStream;
54
55
56class RCCResourceLibrary
57{
58 RCCResourceLibrary(const RCCResourceLibrary &);
59 RCCResourceLibrary &operator=(const RCCResourceLibrary &);
60
61public:
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
102private:
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
151QT_END_NAMESPACE
152
153#endif // RCC_H
Note: See TracBrowser for help on using the repository browser.