QtCraft API C++ classes QML types Handbook

QcStackReader Class

Reads item stacks of one save file by name (written by QcSaveFile::writeStack) with their data (QcItemDataCodec); an unknown item is dropped with one warning per name (QcLoadWarnings::addOnce), counts and damage are clamped to what the item allows (a stack with contents holds one item). More...

Header: #include <server/storage/QcStackReader.h>

Public Types

struct Saved

Public Functions

QcItemStack fitted(const QcStackReader::Saved &saved) const
QcItemStack read(QDataStream &stream)
std::optional<QcItemData> readData(QDataStream &stream, int depth)

Detailed Description

Damaged data turns the stream corrupt (QDataStream::ReadCorruptData). A filled map saved before E-823 with its map id in damage gets it as its map id.

Member Function Documentation

QcItemStack QcStackReader::fitted(const QcStackReader::Saved &saved) const

Returns the stack saved of a known item within the item's limits (count, damage, a name's length; a filled map's id moved from its damage, see above).

QcItemStack QcStackReader::read(QDataStream &stream)

Returns the stack of one slot read from stream; empty for an empty slot, an unknown item or damaged data.

std::optional<QcItemData> QcStackReader::readData(QDataStream &stream, int depth)

Returns the data of a stack read from stream whose contents may nest depth levels (QcItemDataCodec); std::nullopt for damaged data. Unknown components are kept, those beyond QcComponentFrames::maxKept dropped with a warning.