mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 06:52:15 -07:00
inline structs in forEachCard
This commit is contained in:
parent
9ee575c1a2
commit
5f1fca5da0
4 changed files with 22 additions and 91 deletions
|
|
@ -762,20 +762,9 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
|
|||
return loadFromStream_Plain(in, false);
|
||||
}
|
||||
|
||||
struct WriteToStream
|
||||
bool DeckList::saveToStream_Plain(QTextStream &stream, bool prefixSideboardCards, bool slashTappedOutSplitCards)
|
||||
{
|
||||
QTextStream &stream;
|
||||
bool prefixSideboardCards;
|
||||
bool slashTappedOutSplitCards;
|
||||
|
||||
WriteToStream(QTextStream &_stream, bool _prefixSideboardCards, bool _slashTappedOutSplitCards)
|
||||
: stream(_stream), prefixSideboardCards(_prefixSideboardCards),
|
||||
slashTappedOutSplitCards(_slashTappedOutSplitCards)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const InnerDecklistNode *node, const DecklistCardNode *card)
|
||||
{
|
||||
auto writeToStream = [&stream, prefixSideboardCards, slashTappedOutSplitCards](const auto node, const auto card) {
|
||||
if (prefixSideboardCards && node->getName() == DECK_ZONE_SIDE) {
|
||||
stream << "SB: ";
|
||||
}
|
||||
|
|
@ -784,12 +773,8 @@ struct WriteToStream
|
|||
} else {
|
||||
stream << QString("%1 %2\n").arg(card->getNumber()).arg(card->getName().replace("//", "/"));
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
bool DeckList::saveToStream_Plain(QTextStream &out, bool prefixSideboardCards, bool slashTappedOutSplitCards)
|
||||
{
|
||||
WriteToStream writeToStream(out, prefixSideboardCards, slashTappedOutSplitCards);
|
||||
forEachCard(writeToStream);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue