Struct qt_core::QResource

source ·
#[repr(C)]
pub struct QResource { /* private fields */ }
Expand description

The QResource class provides an interface for reading directly from resources.

C++ class: QResource.

C++ documentation:

The QResource class provides an interface for reading directly from resources.

QResource is an object that represents a set of data (and possibly children) relating to a single resource entity. QResource gives direct access to the bytes in their raw format. In this way direct access allows reading data without buffer copying or indirection. Indirection is often useful when interacting with the resource entity as if it is a file, this can be achieved with QFile. The data and children behind a QResource are normally compiled into an application/library, but it is also possible to load a resource at runtime. When loaded at run time the resource file will be loaded as one big set of data and then given out in pieces via references into the resource tree.

A QResource can either be loaded with an absolute path, either treated as a file system rooted with a / character, or in resource notation rooted with a : character. A relative resource can also be opened which will be found in the list of paths returned by QDir::searchPaths().

A QResource that is representing a file will have data backing it, this data can possibly be compressed, in which case qUncompress() must be used to access the real data; this happens implicitly when accessed through a QFile. A QResource that is representing a directory will have only children and no data.

Implementations§

source§

impl QResource

source

pub unsafe fn absolute_file_path(&self) -> CppBox<QString>

Returns the real path that this QResource represents, if the resource was found via the QDir::searchPaths() it will be indicated in the path.

Calls C++ function: QString QResource::absoluteFilePath() const.

C++ documentation:

Returns the real path that this QResource represents, if the resource was found via the QDir::searchPaths() it will be indicated in the path.

See also fileName().

source

pub unsafe fn add_search_path(path: impl CastInto<Ref<QString>>)

Use QDir::addSearchPath() with a prefix instead.

Calls C++ function: static void QResource::addSearchPath(const QString& path).

C++ documentation:

Use QDir::addSearchPath() with a prefix instead.

Adds path to the search paths searched in to find resources that are not specified with an absolute path. The path must be an absolute path (start with /).

The default search path is to search only in the root (:/). The last path added will be consulted first upon next QResource creation.

source

pub unsafe fn compression_algorithm(&self) -> Compression

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the compression type that this resource is compressed with, if any. If it is not compressed, this function returns QResource::NoCompression.

Calls C++ function: QResource::Compression QResource::compressionAlgorithm() const.

C++ documentation:

Returns the compression type that this resource is compressed with, if any. If it is not compressed, this function returns QResource::NoCompression.

If this function returns QResource::ZlibCompression, you may decompress the data using the qUncompress() function. Up until Qt 5.13, this was the only possible compression algorithm.

If this function returns QResource::ZstdCompression, you need to use the Zstandard library functios (<zstd.h> header). Qt does not provide a wrapper. See \l{http://facebook.github.io/zstd/zstd_manual.html}{Zstandard manual}. \sa isCompressed(), data(), isFile()

This function was introduced in Qt 5.13.

source

pub unsafe fn data(&self) -> *const c_uchar

Returns direct access to a read only segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory 0 is returned.

Calls C++ function: const unsigned char* QResource::data() const.

C++ documentation:

Returns direct access to a read only segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory 0 is returned.

See also size(), isCompressed(), and isFile().

source

pub unsafe fn file_name(&self) -> CppBox<QString>

Returns the full path to the file that this QResource represents as it was passed.

Calls C++ function: QString QResource::fileName() const.

C++ documentation:

Returns the full path to the file that this QResource represents as it was passed.

See also setFileName() and absoluteFilePath().

source

pub unsafe fn is_compressed(&self) -> bool

Returns true if the resource represents a file and the data backing it is in a compressed format, false otherwise.

Calls C++ function: bool QResource::isCompressed() const.

C++ documentation:

Returns true if the resource represents a file and the data backing it is in a compressed format, false otherwise.

See also data() and isFile().

source

pub unsafe fn is_valid(&self) -> bool

Returns true if the resource really exists in the resource hierarchy, false otherwise.

Calls C++ function: bool QResource::isValid() const.

C++ documentation:

Returns true if the resource really exists in the resource hierarchy, false otherwise.

source

pub unsafe fn last_modified(&self) -> CppBox<QDateTime>

Returns the date and time when the file was last modified before packaging into a resource.

Calls C++ function: QDateTime QResource::lastModified() const.

C++ documentation:

Returns the date and time when the file was last modified before packaging into a resource.

source

pub unsafe fn locale(&self) -> CppBox<QLocale>

Returns the locale used to locate the data for the QResource.

Calls C++ function: QLocale QResource::locale() const.

C++ documentation:

Returns the locale used to locate the data for the QResource.

See also setLocale().

source

pub unsafe fn new_2a( file: impl CastInto<Ref<QString>>, locale: impl CastInto<Ref<QLocale>> ) -> CppBox<QResource>

Constructs a QResource pointing to file. locale is used to load a specific localization of a resource data.

Calls C++ function: [constructor] void QResource::QResource(const QString& file = …, const QLocale& locale = …).

C++ documentation:

Constructs a QResource pointing to file. locale is used to load a specific localization of a resource data.

See also QFileInfo, QDir::searchPaths(), setFileName(), and setLocale().

source

pub unsafe fn new_0a() -> CppBox<QResource>

The QResource class provides an interface for reading directly from resources.

Calls C++ function: [constructor] void QResource::QResource().

C++ documentation:

The QResource class provides an interface for reading directly from resources.

QResource is an object that represents a set of data (and possibly children) relating to a single resource entity. QResource gives direct access to the bytes in their raw format. In this way direct access allows reading data without buffer copying or indirection. Indirection is often useful when interacting with the resource entity as if it is a file, this can be achieved with QFile. The data and children behind a QResource are normally compiled into an application/library, but it is also possible to load a resource at runtime. When loaded at run time the resource file will be loaded as one big set of data and then given out in pieces via references into the resource tree.

A QResource can either be loaded with an absolute path, either treated as a file system rooted with a / character, or in resource notation rooted with a : character. A relative resource can also be opened which will be found in the list of paths returned by QDir::searchPaths().

A QResource that is representing a file will have data backing it, this data can possibly be compressed, in which case qUncompress() must be used to access the real data; this happens implicitly when accessed through a QFile. A QResource that is representing a directory will have only children and no data.

source

pub unsafe fn new_1a(file: impl CastInto<Ref<QString>>) -> CppBox<QResource>

Constructs a QResource pointing to file. locale is used to load a specific localization of a resource data.

Calls C++ function: [constructor] void QResource::QResource(const QString& file = …).

C++ documentation:

Constructs a QResource pointing to file. locale is used to load a specific localization of a resource data.

See also QFileInfo, QDir::searchPaths(), setFileName(), and setLocale().

source

pub unsafe fn register_resource_2_q_string( rcc_filename: impl CastInto<Ref<QString>>, resource_root: impl CastInto<Ref<QString>> ) -> bool

Registers the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Calls C++ function: static bool QResource::registerResource(const QString& rccFilename, const QString& resourceRoot = …).

C++ documentation:

Registers the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

See also unregisterResource().

source

pub unsafe fn register_resource_uchar_q_string( rcc_data: *const c_uchar, resource_root: impl CastInto<Ref<QString>> ) -> bool

Registers the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Calls C++ function: static bool QResource::registerResource(const unsigned char* rccData, const QString& resourceRoot = …).

C++ documentation:

Registers the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Warning: The data must remain valid throughout the life of any QFile that may reference the resource data.

This function was introduced in Qt 4.3.

See also unregisterResource().

source

pub unsafe fn register_resource_q_string( rcc_filename: impl CastInto<Ref<QString>> ) -> bool

Registers the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Calls C++ function: static bool QResource::registerResource(const QString& rccFilename).

C++ documentation:

Registers the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

See also unregisterResource().

source

pub unsafe fn register_resource_uchar(rcc_data: *const c_uchar) -> bool

Registers the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Calls C++ function: static bool QResource::registerResource(const unsigned char* rccData).

C++ documentation:

Registers the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the file is successfully opened; otherwise returns false.

Warning: The data must remain valid throughout the life of any QFile that may reference the resource data.

This function was introduced in Qt 4.3.

See also unregisterResource().

source

pub unsafe fn search_paths() -> CppBox<QStringList>

Use QDir::searchPaths() instead.

Calls C++ function: static QStringList QResource::searchPaths().

C++ documentation:

Use QDir::searchPaths() instead.

Returns the current search path list. This list is consulted when creating a relative resource.

See also QDir::addSearchPath() and QDir::setSearchPaths().

source

pub unsafe fn set_file_name(&self, file: impl CastInto<Ref<QString>>)

Sets a QResource to point to file. file can either be absolute, in which case it is opened directly, if relative then the file will be tried to be found in QDir::searchPaths().

Calls C++ function: void QResource::setFileName(const QString& file).

C++ documentation:

Sets a QResource to point to file. file can either be absolute, in which case it is opened directly, if relative then the file will be tried to be found in QDir::searchPaths().

See also fileName() and absoluteFilePath().

source

pub unsafe fn set_locale(&self, locale: impl CastInto<Ref<QLocale>>)

Sets a QResource to only load the localization of resource to for locale. If a resource for the specific locale is not found then the C locale is used.

Calls C++ function: void QResource::setLocale(const QLocale& locale).

C++ documentation:

Sets a QResource to only load the localization of resource to for locale. If a resource for the specific locale is not found then the C locale is used.

See also locale() and setFileName().

source

pub unsafe fn size(&self) -> i64

Returns the size of the data backing the resource.

Calls C++ function: qint64 QResource::size() const.

C++ documentation:

Returns the size of the data backing the resource.

See also data() and isFile().

source

pub unsafe fn unregister_resource_2_q_string( rcc_filename: impl CastInto<Ref<QString>>, resource_root: impl CastInto<Ref<QString>> ) -> bool

Unregisters the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist for the resource; otherwise returns false.

Calls C++ function: static bool QResource::unregisterResource(const QString& rccFilename, const QString& resourceRoot = …).

C++ documentation:

Unregisters the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist for the resource; otherwise returns false.

See also registerResource().

source

pub unsafe fn unregister_resource_uchar_q_string( rcc_data: *const c_uchar, resource_root: impl CastInto<Ref<QString>> ) -> bool

Unregisters the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist into the resource; otherwise returns false.

Calls C++ function: static bool QResource::unregisterResource(const unsigned char* rccData, const QString& resourceRoot = …).

C++ documentation:

Unregisters the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist into the resource; otherwise returns false.

This function was introduced in Qt 4.3.

See also registerResource().

source

pub unsafe fn unregister_resource_q_string( rcc_filename: impl CastInto<Ref<QString>> ) -> bool

Unregisters the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist for the resource; otherwise returns false.

Calls C++ function: static bool QResource::unregisterResource(const QString& rccFilename).

C++ documentation:

Unregisters the resource with the given rccFileName at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist for the resource; otherwise returns false.

See also registerResource().

source

pub unsafe fn unregister_resource_uchar(rcc_data: *const c_uchar) -> bool

Unregisters the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist into the resource; otherwise returns false.

Calls C++ function: static bool QResource::unregisterResource(const unsigned char* rccData).

C++ documentation:

Unregisters the resource with the given rccData at the location in the resource tree specified by mapRoot, and returns true if the resource is successfully unloaded and no references exist into the resource; otherwise returns false.

This function was introduced in Qt 4.3.

See also registerResource().

Trait Implementations§

source§

impl CppDeletable for QResource

source§

unsafe fn delete(&self)

Releases the resources of the QResource object.

Calls C++ function: [destructor] void QResource::~QResource().

C++ documentation:

Releases the resources of the QResource object.

source§

impl Data for QResource

source§

unsafe fn data(&self) -> *const c_uchar

Returns direct access to a read only segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory 0 is returned.

Calls C++ function: const unsigned char* QResource::data() const.

C++ documentation:

Returns direct access to a read only segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory 0 is returned.

See also size(), isCompressed(), and isFile().

§

type Output = *const u8

Return type of data() function.
source§

impl Size for QResource

source§

unsafe fn size(&self) -> usize

Returns the size of the data backing the resource.

Calls C++ function: qint64 QResource::size() const.

C++ documentation:

Returns the size of the data backing the resource.

See also data() and isFile().

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.