Cockatrice/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_4.h
BruebachL 95f02ac0a1
[CardDB] Drop the rebalanced-cards setting entirely (#7457)
* [CardDB] Drop rebalanced-card filtering from the v4 parser

Rebalanced cards no longer exist, so the includeRebalancedCards
preference has no data to filter. Always keep printings marked
isRebalanced and remove the now-unused ICardPreferenceProvider
plumbing from CockatriceXml4Parser and CardDatabaseLoader.

The setting itself (CardsDisplaySettings, Manage Sets checkbox,
Oracle attribute mapping) is removed in a follow-up.

* [CardDB] Drop the rebalanced-cards setting entirely

Rebalanced Alchemy cards no longer exist, so remove the
includeRebalancedCards preference surface: the CardsDisplaySettings
getter/setter/signal, the ICardPreferenceProvider and
ICardsDisplaySettingsProvider methods, the Manage Sets checkbox, the
legacy settings migration mapping, the isRebalanced attribute mapping
in the Oracle importer, and the isRebalanced attribute in the v4
schema.

Builds on #7448, which already stopped the v4 parser from filtering
on the preference.

* [CardDB] Drop the unused isOnlineOnly printing property

The Arena-card detection switched from isOnlineOnly to isRebalanced in
#5778, so nothing has read this printing property since; it only
round-trips from the Oracle importer into cards.xml. Remove the
importer mapping, the benchmark fixture field and the v4 schema
attribute so regenerated databases stop carrying it.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-10-09 06:02:47 +02:00

93 lines
No EOL
3.1 KiB
C++

#ifndef COCKATRICE_XML4_H
#define COCKATRICE_XML4_H
#include "card_database_parser.h"
#include "libcockatrice/card/card_info.h"
#include <QHash>
#include <QLoggingCategory>
#include <QString>
#include <qtmetamacros.h>
class ICardSetPriorityController;
class QXmlStreamReader;
inline Q_LOGGING_CATEGORY(CockatriceXml4Log, "cockatrice_xml.xml_4_parser");
/**
* @class CockatriceXml4Parser
* @ingroup CardDatabase
* @brief Parses version 4 of the Cockatrice XML Schema.
*
* This parser reads a Cockatrice XML4 database and emits CardInfoPtr
* and CardSetPtr objects. Card properties are read inside <prop> blocks,
* making the parser more extensible and schema-compliant.
*
* @note Differences from v3:
* - Card properties are stored in <prop> blocks as a QHash<QString, QString>.
* - Sets can include a <priority> element.
* - Related cards support persistent relations and multiple attach types (e.g., transform).
* - More robust serialization; easier to extend schema in the future.
*/
class CockatriceXml4Parser : public ICardDatabaseParser
{
Q_OBJECT
public:
explicit CockatriceXml4Parser(ICardSetPriorityController *cardSetPriorityController);
~CockatriceXml4Parser() 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 XML4 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 Parse the XML database into the given snapshot.
* @param device Open QIODevice positioned at start of file.
* @param data Target snapshot to populate.
*/
void parseFileInto(QIODevice &device, CardDatabaseData &data) override;
/**
* @brief Save sets and cards back to an XML4 file.
*/
bool saveToFile(FormatRulesNameMap _formats,
SetNameMap _sets,
CardNameMap cards,
const QString &fileName,
const QString &sourceUrl = "unknown",
const QString &sourceVersion = "unknown") override;
private:
/**
* @brief Loads a generic <prop> block from a <card> element.
* @param xml The open QXmlStreamReader positioned at a <prop> element.
* @return A QHash<QString, QString> mapping property names to values.
*/
QHash<QString, QString> loadCardPropertiesFromXml(QXmlStreamReader &xml);
/**
* @brief Load all <card> elements from the XML stream.
* @param xml The open QXmlStreamReader positioned at the <cards> element.
*/
void loadCardsFromXml(QXmlStreamReader &xml);
void loadFormats(QXmlStreamReader &xml);
/**
* @brief Load all <set> elements from the XML stream.
* @param xml The open QXmlStreamReader positioned at the <sets> element.
* Parses <set> nodes including priority information.
*/
void loadSetsFromXml(QXmlStreamReader &xml);
};
#endif