mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
[DeckList] Remove dead card XML readElement (#7301)
* [DeckList] Remove no-op card XML readElement AbstractDecklistCardNode::readElement only advanced the XML reader to </card> and always returned 0; a card's attributes were already parsed by the parent InnerDecklistNode::readElement. The containing zone loop skips the card's end tag itself, so the method was dead weight and is dropped from the node interface along with the pure virtual it existed to satisfy. * [DeckList] Document writeElement as the only serialization method --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
61c1215a30
commit
87443d58f7
5 changed files with 6 additions and 28 deletions
|
|
@ -34,17 +34,6 @@ bool AbstractDecklistCardNode::compareName(AbstractDecklistNode *other) const
|
|||
}
|
||||
}
|
||||
|
||||
int AbstractDecklistCardNode::readElement(QXmlStreamReader *xml, int /* limit */)
|
||||
{
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (xml->isEndElement() && xml->name().toString() == "card") {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractDecklistCardNode::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeEmptyElement("card");
|
||||
|
|
|
|||
|
|
@ -134,15 +134,6 @@ public:
|
|||
*/
|
||||
bool compareName(AbstractDecklistNode *other) const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize this node’s properties from XML.
|
||||
* @param xml QXmlStreamReader positioned at the element.
|
||||
* @return true if parsing succeeded.
|
||||
*
|
||||
* This supports loading deck files from Cockatrice’s XML format.
|
||||
*/
|
||||
int readElement(QXmlStreamReader *xml, int limit) override;
|
||||
|
||||
/**
|
||||
* @brief Serialize this node’s properties to XML.
|
||||
* @param xml Writer to append this node’s XML element.
|
||||
|
|
|
|||
|
|
@ -179,11 +179,10 @@ public:
|
|||
|
||||
/**
|
||||
* @name XML serialization
|
||||
* These methods support reading and writing decks from/to
|
||||
* This method supports writing this node and its children to the
|
||||
* Cockatrice deck XML format.
|
||||
* @{
|
||||
*/
|
||||
virtual int readElement(QXmlStreamReader *xml, int limit) = 0;
|
||||
virtual void writeElement(QXmlStreamWriter *xml) = 0;
|
||||
/// @}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -164,12 +164,11 @@ int InnerDecklistNode::readElement(QXmlStreamReader *xml, int limit)
|
|||
} else if (childName == "card") {
|
||||
int amount = xml->attributes().value("number").toString().toInt();
|
||||
amount = qMin(amount, limit - totalCards);
|
||||
auto *newCard = new DecklistCardNode(xml->attributes().value("name").toString(), amount, this, -1,
|
||||
xml->attributes().value("setShortName").toString(),
|
||||
xml->attributes().value("collectorNumber").toString(),
|
||||
xml->attributes().value("uuid").toString());
|
||||
new DecklistCardNode(xml->attributes().value("name").toString(), amount, this, -1,
|
||||
xml->attributes().value("setShortName").toString(),
|
||||
xml->attributes().value("collectorNumber").toString(),
|
||||
xml->attributes().value("uuid").toString());
|
||||
totalCards += amount;
|
||||
totalCards += newCard->readElement(xml, limit - totalCards);
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "zone")) {
|
||||
return totalCards;
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public:
|
|||
* @param limit The maximum amount of cards to read
|
||||
* @return the amount of cards found
|
||||
*/
|
||||
int readElement(QXmlStreamReader *xml, int limit) override;
|
||||
int readElement(QXmlStreamReader *xml, int limit);
|
||||
|
||||
/**
|
||||
* @brief Serialize this node and its children to XML.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue