Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CockatriceXml3Parser Class Reference

Parses version 3 of the Cockatrice XML Schema. More...

#include <cockatrice_xml_3.h>

Inheritance diagram for CockatriceXml3Parser:
[legend]
Collaboration diagram for CockatriceXml3Parser:
[legend]

Public Member Functions

 CockatriceXml3Parser ()=default
 ~CockatriceXml3Parser () override=default
bool getCanParseFile (const QString &name, QIODevice &device) override
 Determines if the parser can handle this file.
void parseFile (QIODevice &device) override
 Parse the XML database.
bool saveToFile (SetNameMap _sets, CardNameMap cards, const QString &fileName, const QString &sourceUrl="unknown", const QString &sourceVersion="unknown") override
 Save sets and cards back to an XML3 file.
Public Member Functions inherited from ICardDatabaseParser
 ~ICardDatabaseParser () override=default

Private Member Functions

void loadCardsFromXml (QXmlStreamReader &xml)
 Load all <card> elements from the XML stream.
void loadSetsFromXml (QXmlStreamReader &xml)
 Load all <set> elements from the XML stream.
QString getMainCardType (QString &type)
 Extracts the main card type from a full type string.

Additional Inherited Members

Signals inherited from ICardDatabaseParser
void addCard (CardInfoPtr card)
void addSet (CardSetPtr set)
Static Public Member Functions inherited from ICardDatabaseParser
static void clearSetlist ()
 Clears the cached global set list.
Protected Member Functions inherited from ICardDatabaseParser
CardSetPtr internalAddSet (const QString &setName, const QString &longName="", const QString &setType="", const QDate &releaseDate=QDate(), const CardSet::Priority priority=CardSet::PriorityFallback)
 Internal helper to add a set to the global set cache.
Static Protected Attributes inherited from ICardDatabaseParser
static SetNameMap sets
 Cached global list of sets shared between all parsers.

Detailed Description

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.

Constructor & Destructor Documentation

◆ CockatriceXml3Parser()

CockatriceXml3Parser::CockatriceXml3Parser ( )
default

◆ ~CockatriceXml3Parser()

CockatriceXml3Parser::~CockatriceXml3Parser ( )
overridedefault

Member Function Documentation

◆ getCanParseFile()

bool CockatriceXml3Parser::getCanParseFile ( const QString & name,
QIODevice & device )
overridevirtual

Determines if the parser can handle this file.

Parameters
nameFile name.
deviceOpen QIODevice containing the XML.
Returns
True if the file is a Cockatrice XML3 database.

Implements ICardDatabaseParser.

◆ getMainCardType()

QString CockatriceXml3Parser::getMainCardType ( QString & type)
private

Extracts the main card type from a full type string.

Parameters
typeThe full type string (e.g., "Legendary Artifact Creature - Golem")
Returns
The primary type (e.g., "Creature").
Here is the caller graph for this function:

◆ loadCardsFromXml()

void CockatriceXml3Parser::loadCardsFromXml ( QXmlStreamReader & xml)
private

Load all <card> elements from the XML stream.

Parameters
xmlThe open QXmlStreamReader positioned at the <cards> element. Parses each <card> node and emits addCard signals for each CardInfoPtr created.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSetsFromXml()

void CockatriceXml3Parser::loadSetsFromXml ( QXmlStreamReader & xml)
private

Load all <set> elements from the XML stream.

Parameters
xmlThe open QXmlStreamReader positioned at the <sets> element. Parses each <set> node and adds them to the shared set cache.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseFile()

void CockatriceXml3Parser::parseFile ( QIODevice & device)
overridevirtual

Parse the XML database.

Parameters
deviceOpen QIODevice positioned at start of file.

Implements ICardDatabaseParser.

Here is the call graph for this function:

◆ saveToFile()

bool CockatriceXml3Parser::saveToFile ( SetNameMap _sets,
CardNameMap cards,
const QString & fileName,
const QString & sourceUrl = "unknown",
const QString & sourceVersion = "unknown" )
overridevirtual

Save sets and cards back to an XML3 file.

Implements ICardDatabaseParser.


The documentation for this class was generated from the following files: