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

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

#include <cockatrice_xml_4.h>

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

Public Member Functions

 CockatriceXml4Parser (ICardPreferenceProvider *cardPreferenceProvider)
 ~CockatriceXml4Parser () 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 XML4 file.
Public Member Functions inherited from ICardDatabaseParser
 ~ICardDatabaseParser () override=default

Private Member Functions

QVariantHash loadCardPropertiesFromXml (QXmlStreamReader &xml)
 Loads a generic <prop> block from a <card> element.
void loadCardsFromXml (QXmlStreamReader &xml)
 Load all <card> elements from the XML stream.
void loadSetsFromXml (QXmlStreamReader &xml)
 Load all <set> elements from the XML stream.

Private Attributes

ICardPreferenceProvidercardPreferenceProvider
 Interface to handle user preferences.

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 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 QVariantHash.
  • Sets can include a <priority> element.
  • Supports user preferences via ICardPreferenceProvider (e.g., skipping rebalanced cards).
  • Related cards support persistent relations and multiple attach types (e.g., transform).
  • More robust serialization; easier to extend schema in the future.

Constructor & Destructor Documentation

◆ CockatriceXml4Parser()

CockatriceXml4Parser::CockatriceXml4Parser ( ICardPreferenceProvider * cardPreferenceProvider)
explicit

◆ ~CockatriceXml4Parser()

CockatriceXml4Parser::~CockatriceXml4Parser ( )
overridedefault

Member Function Documentation

◆ getCanParseFile()

bool CockatriceXml4Parser::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 XML4 database.

Implements ICardDatabaseParser.

◆ loadCardPropertiesFromXml()

QVariantHash CockatriceXml4Parser::loadCardPropertiesFromXml ( QXmlStreamReader & xml)
private

Loads a generic <prop> block from a <card> element.

Parameters
xmlThe open QXmlStreamReader positioned at a <prop> element.
Returns
A QVariantHash mapping property names to values.
Here is the caller graph for this function:

◆ loadCardsFromXml()

void CockatriceXml4Parser::loadCardsFromXml ( QXmlStreamReader & xml)
private

Load all <card> elements from the XML stream.

Parameters
xmlThe open QXmlStreamReader positioned at the <cards> element. Honors the user's preference regarding rebalanced cards.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSetsFromXml()

void CockatriceXml4Parser::loadSetsFromXml ( QXmlStreamReader & xml)
private

Load all <set> elements from the XML stream.

Parameters
xmlThe open QXmlStreamReader positioned at the <sets> element. Parses <set> nodes including priority information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseFile()

void CockatriceXml4Parser::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 CockatriceXml4Parser::saveToFile ( SetNameMap _sets,
CardNameMap cards,
const QString & fileName,
const QString & sourceUrl = "unknown",
const QString & sourceVersion = "unknown" )
overridevirtual

Save sets and cards back to an XML4 file.

Implements ICardDatabaseParser.

Here is the caller graph for this function:

Member Data Documentation

◆ cardPreferenceProvider

ICardPreferenceProvider* CockatriceXml4Parser::cardPreferenceProvider
private

Interface to handle user preferences.


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