1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2019 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QRESOURCE_H
6#define QRESOURCE_H
7
8#include <QtCore/qstring.h>
9#include <QtCore/qlocale.h>
10#include <QtCore/qstringlist.h>
11#include <QtCore/qlist.h>
12#include <QtCore/qscopedpointer.h>
13
14QT_BEGIN_NAMESPACE
15
16
17class QResourcePrivate;
18
19class Q_CORE_EXPORT QResource
20{
21public:
22 enum Compression {
23 NoCompression,
24 ZlibCompression,
25 ZstdCompression
26 };
27
28 QResource(const QString &file = QString(), const QLocale &locale = QLocale());
29 ~QResource();
30
31 void setFileName(const QString &file);
32 QString fileName() const;
33 QString absoluteFilePath() const;
34
35 void setLocale(const QLocale &locale);
36 QLocale locale() const;
37
38 bool isValid() const;
39
40 Compression compressionAlgorithm() const;
41 qint64 size() const;
42 const uchar *data() const;
43 qint64 uncompressedSize() const;
44 QByteArray uncompressedData() const;
45 QDateTime lastModified() const;
46
47 static bool registerResource(const QString &rccFilename, const QString &resourceRoot=QString());
48 static bool unregisterResource(const QString &rccFilename, const QString &resourceRoot=QString());
49
50 static bool registerResource(const uchar *rccData, const QString &resourceRoot=QString());
51 static bool unregisterResource(const uchar *rccData, const QString &resourceRoot=QString());
52
53protected:
54 friend class QResourceFileEngine;
55 friend class QResourceFileEngineIterator;
56 bool isDir() const;
57 inline bool isFile() const { return !isDir(); }
58 QStringList children() const;
59
60protected:
61 QScopedPointer<QResourcePrivate> d_ptr;
62
63private:
64 Q_DECLARE_PRIVATE(QResource)
65};
66
67QT_END_NAMESPACE
68
69#endif // QRESOURCE_H
70

source code of qtbase/src/corelib/io/qresource.h