mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 11:03:54 -07:00
* Deck legality checker. Took 51 seconds Took 1 minute Took 1 minute Took 5 minutes Took 3 minutes * Adjust format parsing. Took 8 minutes Took 3 seconds * toString() the xmlName Took 4 minutes * more toStrings() Took 5 minutes * Comments Took 3 minutes * Layout Took 2 minutes * Layout part 2: Electric boogaloo Took 59 seconds * Update cockatrice/src/interface/widgets/visual_database_display/visual_database_display_format_legality_filter_widget.cpp Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com> * Move layout. Took 4 minutes Took 10 seconds * Emit deckModified Took 6 minutes * Fix qOverloads Took 4 minutes * Fix qOverloads Took 12 seconds * Consider text and name in a special way. Took 11 minutes * Adjust "Any number of" oracle text Took 5 minutes * Store allowedCounts by format Took 15 minutes Took 6 seconds * Only restrict vintage. Took 2 minutes * Adjust for DBConverter. Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>
79 lines
No EOL
2.6 KiB
C++
79 lines
No EOL
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() = default;
|
|
~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 |