Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qresource.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
5
6#ifndef QRESOURCE_H
7#define QRESOURCE_H
8
9#include <QtCore/qstring.h>
10#include <QtCore/qlocale.h>
11#include <QtCore/qstringlist.h>
12#include <QtCore/qlist.h>
13#include <QtCore/qscopedpointer.h>
14
15QT_BEGIN_NAMESPACE
16
17
18class QResourcePrivate;
19
20class Q_CORE_EXPORT QResource
21{
22public:
23 enum Compression {
24 NoCompression,
25 ZlibCompression,
26 ZstdCompression
27 };
28
29 QResource(const QString &file = QString(), const QLocale &locale = QLocale());
30 ~QResource();
31
32 void setFileName(const QString &file);
33 QString fileName() const;
34 QString absoluteFilePath() const;
35
36 void setLocale(const QLocale &locale);
37 QLocale locale() const;
38
39 bool isValid() const;
40
41 Compression compressionAlgorithm() const;
42 qint64 size() const;
43 const uchar *data() const;
44 qint64 uncompressedSize() const;
45 QByteArray uncompressedData() const;
46 QDateTime lastModified() const;
47
48 static bool registerResource(const QString &rccFilename, const QString &resourceRoot=QString());
49 static bool unregisterResource(const QString &rccFilename, const QString &resourceRoot=QString());
50
51 static bool registerResource(const uchar *rccData, const QString &resourceRoot=QString());
52 static bool unregisterResource(const uchar *rccData, const QString &resourceRoot=QString());
53
54protected:
55 friend class QResourceFileEngine;
56 friend class QResourceFileEngineIterator;
57 bool isDir() const;
58 inline bool isFile() const { return !isDir(); }
59 QStringList children() const;
60
61protected:
62 QScopedPointer<QResourcePrivate> d_ptr;
63
64private:
65 Q_DECLARE_PRIVATE(QResource)
66};
67
68QT_END_NAMESPACE
69
70#endif // QRESOURCE_H
Definition qlist.h:80
QResourceFileEnginePrivate(QAbstractFileEngine *q)
bool caseSensitive() const override
Should return true if the underlying file system is case-sensitive; otherwise return false.
bool flush() override
Flushes the open file, returning true if successful; otherwise returns false.
qint64 read(char *data, qint64 maxlen) override
Reads a number of characters from the file into data.
bool close() override
Closes the file, returning true if successful; otherwise returns false.
bool open(QIODevice::OpenMode flags, std::optional< QFile::Permissions > permissions) override
Opens the file in the specified mode.
bool seek(qint64) override
Sets the file position to the given offset.
qint64 pos() const override
Returns the current file position.
QString fileName(QAbstractFileEngine::FileName file) const override
Return the file engine's current file name in the format specified by file.
qint64 size() const override
Returns the size of the file.
bool extension(Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr) override
virtual bool atEnd() const
uint ownerId(FileOwner) const override
If owner is OwnerUser return the ID of the user who owns the file.
bool supportsExtension(Extension extension) const override
void ensureChildren() const
static bool mayRemapData(const QResource &resource)
void ensureInitialized() const
QList< QResourceRoot * > related
QResource * q_ptr
QResourcePrivate(QResource *_q)
QString absoluteFilePath
QStringList children
qsizetype decompress(char *buffer, qsizetype bufferSize) const
bool load(const QString &file)
const uchar * data
\inmodule QtCore
Definition qresource.h:21
static ResourceList * resourceList()
#define RCC_FEATURE_SYMBOL(feature)
Definition qresource.cpp:66
static QRecursiveMutex & resourceMutex()
Q_DECLARE_TYPEINFO(QResourceRoot, Q_RELOCATABLE_TYPE)
static auto mappingBoundaries(const void *location, qsizetype size)
QList< QResourceRoot * > ResourceList
Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tree, const unsigned char *name, const unsigned char *data)
static QString qt_resource_fixResourceRoot(QString r)
Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, const unsigned char *name, const unsigned char *data)