mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 17:55:21 -05:00
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 11) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 43) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 42) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Servatrice_Debian, DEB, yes, skip, 11) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, skip, 22.04) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Windows10-installer, true, Visual Studio 17 2022, x64, 1, Windows, -Win10, win64_msvc2019_64, qtimageformats qtmultimedia qt… (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Windows7-installer, true, Visual Studio 17 2022, x64, 1, Windows, -Win7, win64_msvc2019_64, 5.15.*, windows-2022, 7, Release) (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (false, Ninja, macOS, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, macos-15, Apple, 15, Debug, 1, 16.4) (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS13_Intel-package, false, Ninja, 1, macOS, 13, -macOS13_Intel, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*… (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS14-package, false, Ninja, 1, macOS, -macOS14, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, macos-14, Appl… (push) Has been cancelled
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS15-package, false, Ninja, 1, macOS, -macOS15, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, macos-15, Appl… (push) Has been cancelled
* [Card DB] Properly pass along set priority controller to parsers Took 16 minutes Took 35 seconds * More adjustments. Took 13 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
79 lines
2.6 KiB
C++
79 lines
2.6 KiB
C++
#ifndef COCKATRICE_XML3_H
|
|
#define COCKATRICE_XML3_H
|
|
|
|
#include "card_database_parser.h"
|
|
|
|
#include <QLoggingCategory>
|
|
#include <QXmlStreamReader>
|
|
|
|
inline Q_LOGGING_CATEGORY(CockatriceXml3Log, "cockatrice_xml.xml_3_parser");
|
|
|
|
/**
|
|
* @class CockatriceXml3Parser
|
|
* @ingroup CardDatabase
|
|
* @brief Parses version 3 of the Cockatrice XML Schema.
|
|
*
|
|
* This parser reads a Cockatrice XML3 database and emits CardInfoPtr
|
|
* and CardSetPtr objects. All card properties are read individually.
|
|
*
|
|
* @note Differences from v4:
|
|
* - No <prop> block; properties are hardcoded (manacost, cmc, type, pt, loyalty, etc.).
|
|
* - No set priority field.
|
|
* - No support for rebalanced cards or preferences.
|
|
* - Related cards support only attach, exclude, variable, and count attributes.
|
|
*/
|
|
class CockatriceXml3Parser : public ICardDatabaseParser
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CockatriceXml3Parser(ICardSetPriorityController *cardSetPriorityController);
|
|
~CockatriceXml3Parser() override = default;
|
|
|
|
/**
|
|
* @brief Determines if the parser can handle this file.
|
|
* @param name File name.
|
|
* @param device Open QIODevice containing the XML.
|
|
* @return True if the file is a Cockatrice XML3 database.
|
|
*/
|
|
bool getCanParseFile(const QString &name, QIODevice &device) override;
|
|
|
|
/**
|
|
* @brief Parse the XML database.
|
|
* @param device Open QIODevice positioned at start of file.
|
|
*/
|
|
void parseFile(QIODevice &device) override;
|
|
|
|
/**
|
|
* @brief Save sets and cards back to an XML3 file.
|
|
*/
|
|
bool saveToFile(FormatRulesNameMap _formats,
|
|
SetNameMap _sets,
|
|
CardNameMap cards,
|
|
const QString &fileName,
|
|
const QString &sourceUrl = "unknown",
|
|
const QString &sourceVersion = "unknown") override;
|
|
|
|
private:
|
|
/**
|
|
* @brief Load all <card> elements from the XML stream.
|
|
* @param xml The open QXmlStreamReader positioned at the <cards> element.
|
|
* Parses each <card> node and emits addCard signals for each CardInfoPtr created.
|
|
*/
|
|
void loadCardsFromXml(QXmlStreamReader &xml);
|
|
|
|
/**
|
|
* @brief Load all <set> elements from the XML stream.
|
|
* @param xml The open QXmlStreamReader positioned at the <sets> element.
|
|
* Parses each <set> node and adds them to the shared set cache.
|
|
*/
|
|
void loadSetsFromXml(QXmlStreamReader &xml);
|
|
|
|
/**
|
|
* @brief Extracts the main card type from a full type string.
|
|
* @param type The full type string (e.g., "Legendary Artifact Creature - Golem")
|
|
* @return The primary type (e.g., "Creature").
|
|
*/
|
|
QString getMainCardType(QString &type);
|
|
};
|
|
|
|
#endif |