C

BinaryResource Struct

struct Qul::BinaryResource

Interface for accessing BinaryFiles. More...

Header: #include <qul/binaryresource.h>
Since: Qt Quick Ultralite 2.9

Public Functions

BinaryResource(const char *uri)
BinaryResource()
size_t alignment() const
const uchar *data() const
size_t size() const

Detailed Description

The BinaryResource provides an interface for accessing BinaryFiles from the Qt Quick Ultralite resource system.

Use the BinaryFiles.files QmlProject property to add resources to a Qt Quick Ultralite application.

BinaryFiles {
    files: [
        "data/foo.bar",
     ]
 }

Access the binary data with the BinaryResource object:

Qul::BinaryResource resource("data/foo.bar");

const uchar* data = resource;

for(size_t i = 0; i < resource.size(); i++) {
    const uchar byte = data[i];
    // ...
}

Member Function Documentation

[since Qt Quick Ultralite 2.9] BinaryResource::BinaryResource(const char *uri)

Construct a BinaryResource for the resource located in uri.

This function was introduced in Qt Quick Ultralite 2.9.

[since Qt Quick Ultralite 2.9] BinaryResource::BinaryResource()

Construct a null BinaryResource.

This function was introduced in Qt Quick Ultralite 2.9.

[since Qt Quick Ultralite 2.9] size_t BinaryResource::alignment() const

Returns byte aligment of the start address of the binary data.

Example usage:

Qul::BinaryResource resource("data/foo.bar");

void *ptr = aligned_alloc(resource.alignment(), resource.size());
if (ptr) {
    memcpy(ptr, resource.data(), resource.size());
}

This function was introduced in Qt Quick Ultralite 2.9.

[since Qt Quick Ultralite 2.9] const uchar *BinaryResource::data() const

Returns start address of the binary data.

This function was introduced in Qt Quick Ultralite 2.9.

[since Qt Quick Ultralite 2.9] size_t BinaryResource::size() const

Returns size of the data in bytes.

This function was introduced in Qt Quick Ultralite 2.9.

Available under certain Qt licenses.
Find out more.