1 /*
2  * DQt - D bindings for the Qt Toolkit
3  *
4  * GNU Lesser General Public License Usage
5  * This file may be used under the terms of the GNU Lesser
6  * General Public License version 3 as published by the Free Software
7  * Foundation and appearing in the file LICENSE.LGPL3 included in the
8  * packaging of this file. Please review the following information to
9  * ensure the GNU Lesser General Public License version 3 requirements
10  * will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
11  */
12 module qt.core.resource;
13 extern(C++):
14 
15 import qt.config;
16 import qt.core.bytearray;
17 import qt.core.datetime;
18 import qt.core.global;
19 import qt.core.locale;
20 import qt.core.scopedpointer;
21 import qt.core.string;
22 import qt.core.stringlist;
23 import qt.helpers;
24 
25 extern(C++, class) struct QResourcePrivate;
26 
27 /// Binding for C++ class [QResource](https://doc.qt.io/qt-6/qresource.html).
28 extern(C++, class) struct /+ Q_CORE_EXPORT +/ QResource
29 {
30 public:
31     enum Compression {
32         NoCompression,
33         ZlibCompression,
34         ZstdCompression
35     }
36 
37     @disable this();
38     this(ref const(QString) file/* = globalInitVar!QString*/, ref const(QLocale) locale/* = globalInitVar!QLocale*/);
39     ~this();
40 
41     void setFileName(ref const(QString) file);
42     QString fileName() const;
43     QString absoluteFilePath() const;
44 
45     void setLocale(ref const(QLocale) locale);
46     QLocale locale() const;
47 
48     bool isValid() const;
49 
50     Compression compressionAlgorithm() const;
51     qint64 size() const;
52     const(uchar)* data() const;
53     qint64 uncompressedSize() const;
54     QByteArray uncompressedData() const;
55     QDateTime lastModified() const;
56 
57     static bool registerResource(ref const(QString) rccFilename, ref const(QString) resourceRoot=globalInitVar!QString);
58     static bool unregisterResource(ref const(QString) rccFilename, ref const(QString) resourceRoot=globalInitVar!QString);
59 
60     static bool registerResource(const(uchar)* rccData, ref const(QString) resourceRoot=globalInitVar!QString);
61     static bool unregisterResource(const(uchar)* rccData, ref const(QString) resourceRoot=globalInitVar!QString);
62 
63 protected:
64     /+ friend class QResourceFileEngine; +/
65     /+ friend class QResourceFileEngineIterator; +/
66     bool isDir() const;
67     pragma(inline, true) bool isFile() const { return !isDir(); }
68     QStringList children() const;
69 
70 protected:
71     QScopedPointer!(QResourcePrivate) d_ptr;
72 
73 private:
74     /+ Q_DECLARE_PRIVATE(QResource) +/
75     mixin(CREATE_CONVENIENCE_WRAPPERS);
76 }
77