7#include <QRegularExpression> 
  100        stream << 
"#include <QtQml/qqmlprivate.h>\n";
 
  101        stream << 
"#include <QtCore/qdir.h>\n";
 
  102        stream << 
"#include <QtCore/qurl.h>\n";
 
  103        stream << 
"#include <QtCore/qhash.h>\n";
 
  104        stream << 
"#include <QtCore/qstring.h>\n";
 
  107        stream << 
"namespace QmlCacheGeneratedCode {\n";
 
  108        for (
int i = 0; 
i < compiledFiles.size(); ++
i) {
 
  109            const QString compiledFile = compiledFiles.at(
i);
 
  111            stream << 
"namespace " << 
ns << 
" { \n";
 
  112            stream << 
"    extern const unsigned char qmlData[];\n";
 
  113            stream << 
"    extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];\n";
 
  114            stream << 
"    const QQmlPrivate::CachedQmlUnit unit = {\n";
 
  115            stream << 
"        reinterpret_cast<const QV4::CompiledData::Unit*>(&qmlData), &aotBuiltFunctions[0], nullptr\n";
 
  121        stream << 
"namespace {\n";
 
  123        stream << 
"struct Registry {\n";
 
  124        stream << 
"    Registry();\n";
 
  125        stream << 
"    ~Registry();\n";
 
  126        stream << 
"    QHash<QString, const QQmlPrivate::CachedQmlUnit*> resourcePathToCachedUnit;\n";
 
  127        stream << 
"    static const QQmlPrivate::CachedQmlUnit *lookupCachedUnit(const QUrl &url);\n";
 
  129        stream << 
"Q_GLOBAL_STATIC(Registry, unitRegistry)\n";
 
  132        stream << 
"Registry::Registry() {\n";
 
  134        for (
int i = 0; 
i < compiledFiles.size(); ++
i) {
 
  135            const QString qrcFile = compiledFiles.at(
i);
 
  137            stream << 
"    resourcePathToCachedUnit.insert(QStringLiteral(\"" << qrcFile << 
"\"), &QmlCacheGeneratedCode::" << 
ns << 
"::unit);\n";
 
  140        stream << 
"    QQmlPrivate::RegisterQmlUnitCacheHook registration;\n";
 
  141        stream << 
"    registration.structVersion = 0;\n";
 
  142        stream << 
"    registration.lookupCachedQmlUnit = &lookupCachedUnit;\n";
 
  143        stream << 
"    QQmlPrivate::qmlregister(QQmlPrivate::QmlUnitCacheHookRegistration, ®istration);\n";
 
  146        stream << 
"Registry::~Registry() {\n";
 
  147        stream << 
"    QQmlPrivate::qmlunregister(QQmlPrivate::QmlUnitCacheHookRegistration, quintptr(&lookupCachedUnit));\n";
 
  150        stream << 
"const QQmlPrivate::CachedQmlUnit *Registry::lookupCachedUnit(const QUrl &url) {\n";
 
  151        stream << 
"    if (url.scheme() != QLatin1String(\"qrc\"))\n";
 
  152        stream << 
"        return nullptr;\n";
 
  153        stream << 
"    QString resourcePath = QDir::cleanPath(url.path());\n";
 
  154        stream << 
"    if (resourcePath.isEmpty())\n";
 
  155        stream << 
"        return nullptr;\n";
 
  156        stream << 
"    if (!resourcePath.startsWith(QLatin1Char('/')))\n";
 
  157        stream << 
"        resourcePath.prepend(QLatin1Char('/'));\n";
 
  158        stream << 
"    return unitRegistry()->resourcePathToCachedUnit.value(resourcePath, nullptr);\n";
 
  166            if (mappingSplit != -1) {
 
  167                newResourceFile = originalResourceFile.
mid(mappingSplit + 1);
 
  168                originalResourceFile.
truncate(mappingSplit);
 
  175            stream << 
"    ::unitRegistry();\n";
 
  176            if (!newResourceFile.
isEmpty())
 
  180            stream << 
"Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(" << initFunction << 
"))\n";
 
  184            if (!newResourceFile.
isEmpty())
 
  191#if QT_CONFIG(temporaryfile) 
  197        *errorString = 
f.errorString();
 
  201    if (
f.write(generatedLoaderCode) != generatedLoaderCode.
size()) {
 
  202        *errorString = 
f.errorString();
 
  206#if QT_CONFIG(temporaryfile) 
  208        *errorString = 
f.errorString();
 
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
 
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
 
\inmodule QtCore \reentrant
 
QString baseName() const
Returns the base name of the file without the path.
 
QString completeSuffix() const
Returns the complete suffix (extension) of the file.
 
QString fileName() const
Returns the name of the file, excluding the path.
 
QString completeBaseName() const
Returns the complete base name of the file without the path.
 
QString path() const
Returns the file's path.
 
\inmodule QtCore \reentrant
 
\macro QT_RESTRICTED_CAST_FROM_ASCII
 
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
 
QString & replace(qsizetype i, qsizetype len, QChar after)
 
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
 
void truncate(qsizetype pos)
Truncates the string at the given position index.
 
void clear()
Clears the contents of the string and makes it null.
 
qsizetype size() const
Returns the number of characters in this string.
 
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
 
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
 
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
 
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
 
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
Combined button and popup list for selecting options.
 
GLenum GLenum GLenum GLenum mapping
 
static QString qtResourceNameForFile(const QString &fileName)
 
bool qQmlJSGenerateLoader(const QStringList &compiledFiles, const QString &outputFileName, const QStringList &resourceFileMappings, QString *errorString)
 
QT_BEGIN_NAMESPACE QString mangledIdentifier(const QString &str)
 
QString qQmlJSSymbolNamespaceForPath(const QString &relativePath)
 
QLatin1StringView QLatin1String
 
#define QStringLiteral(str)
 
QFileInfo fi("c:/temp/foo")
[newstuff]
 
\inmodule QtCore \reentrant