aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod/src/xmlreader.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/installer_fomod/src/xmlreader.cpp
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/installer_fomod/src/xmlreader.cpp')
-rw-r--r--libs/installer_fomod/src/xmlreader.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/libs/installer_fomod/src/xmlreader.cpp b/libs/installer_fomod/src/xmlreader.cpp
new file mode 100644
index 0000000..7f53710
--- /dev/null
+++ b/libs/installer_fomod/src/xmlreader.cpp
@@ -0,0 +1,83 @@
+#include "xmlreader.h"
+
+#include <QDebug>
+
+#include <uibase/utility.h>
+
+using MOBase::Exception;
+
+bool XmlReader::getNextElement(QString const& start)
+{
+ while (!atEnd()) {
+ switch (readNext()) {
+ case EndElement:
+ if (name() != start) {
+ qWarning() << "Got end of " << name() << ", expected " << start << " at "
+ << lineNumber();
+ continue;
+ }
+ return false;
+
+ case StartElement:
+ return true;
+
+ case Invalid:
+ throw Exception("bad xml");
+
+ default:
+ qWarning() << "Unexpected token type " << tokenString() << " at " << lineNumber();
+ }
+ }
+ return false;
+}
+
+void XmlReader::unexpected()
+{
+ qWarning() << "Unexpected element " << name() << " near line " << lineNumber();
+ // Eat the contents
+ QString s = readElementText(IncludeChildElements);
+ // Print them out if in debugging mode
+ qDebug() << " contains " << s;
+}
+
+void XmlReader::finishedElement()
+{
+ QString const self = name().toString();
+ while (!atEnd()) {
+ switch (readNext()) {
+ case EndElement:
+ if (name() != self) {
+ qWarning() << "Got end element for " << name() << ", expected " << self
+ << " at " << lineNumber();
+ continue;
+ }
+ return;
+
+ case Invalid:
+ throw Exception("bad xml");
+ return;
+
+ case StartElement:
+ unexpected();
+ break;
+
+ default:
+ qWarning() << "Unexpected token type " << tokenString() << " at " << lineNumber();
+ }
+ }
+}
+
+QString XmlReader::getText()
+{
+ // This reads the text in an element, leaving you at the next element.
+ QString result;
+ while (QXmlStreamReader::readNext() == Comment || tokenType() == Characters) {
+ if (tokenType() == Characters) {
+ result += text();
+ }
+ }
+ if (tokenType() != EndElement) {
+ qWarning() << "Unexpected token type " << tokenString() << " at " << lineNumber();
+ }
+ return result;
+}