6#include <QXmlStreamReader>
41 QXmlStreamWriter writer(&outputString);
42 writer.setAutoFormatting(
true);
44 QXmlStreamReader reader(&
file);
45 while (!reader.atEnd()) {
46 switch (reader.readNext()) {
47 case QXmlStreamReader::StartDocument: {
50 writer.writeStartDocument(version.
toString());
52 writer.writeStartDocument();
55 case QXmlStreamReader::EndDocument:
56 writer.writeEndDocument();
58 case QXmlStreamReader::StartElement:
60 if (
state != InitialState) {
61 fprintf(stderr,
"Unexpected RCC tag in line %d\n",
int(reader.lineNumber()));
67 fprintf(stderr,
"Unexpected qresource tag in line %d\n",
int(reader.lineNumber()));
79 if (
state != InResource) {
80 fprintf(stderr,
"Unexpected file tag in line %d\n",
int(reader.lineNumber()));
84 fileAttributes = reader.attributes();
87 writer.writeStartElement(reader.name().toString());
88 writer.writeAttributes(reader.attributes());
91 case QXmlStreamReader::EndElement:
93 if (
state != InFile) {
94 fprintf(stderr,
"Unexpected end of file tag in line %d\n",
int(reader.lineNumber()));
100 if (
state != InResource) {
101 fprintf(stderr,
"Unexpected end of qresource tag in line %d\n",
int(reader.lineNumber()));
106 if (
state != InRCC) {
107 fprintf(stderr,
"Unexpected end of RCC tag in line %d\n",
int(reader.lineNumber()));
110 state = InitialState;
112 writer.writeEndElement();
115 case QXmlStreamReader::Characters:
116 if (reader.isWhitespace())
120 currentFileName = reader.
text().toString();
132 writer.writeAttributes(fileAttributes);
133 writer.writeCharacters(currentFileName);
134 writer.writeEndElement();
147 if (
outputFile.write(outputStringUtf8) != outputStringUtf8.
size())
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
QString relativeFilePath(const QString &fileName) const
Returns the path to fileName relative to the directory.
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
\inmodule QtCore \reentrant
QDir absoluteDir() const
Returns the file's absolute path as a QDir object.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QString text(const QString &key) const
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
QString toString() const
Returns a deep copy of this string view's data as a QString.
\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.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & append(QChar c)
QByteArray toUtf8() const &
QString & prepend(QChar c)
Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value)
bool hasAttribute(QAnyStringView qualifiedName) const
Q_CORE_EXPORT QStringView value(QAnyStringView namespaceUri, QAnyStringView name) const noexcept
Combined button and popup list for selecting options.
static QString outputFile
GLenum GLenum GLenum input
QT_BEGIN_NAMESPACE int qRelocateResourceFile(const QString &input, const QString &output)
#define qPrintable(string)
#define QStringLiteral(str)
QT_BEGIN_NAMESPACE typedef uchar * output
\inmodule QtCore \reentrant